MakeMusic
SmartMusic Finale Garritan MusicXML

MusicXML and non-DOM data structures

Moderator: Michael Good

MusicXML and non-DOM data structures

Postby Jane Singer » Thu Nov 14, 2002 11:40 am

I've been trying to come up with a way to incorporate methods that can differentiate between different "types" of nodes in a Dom object built from MusicXML - such as eighth notes, quarter notes. The problem is that XML
(DOM) itself does not do this. They are all just nodes. I would like to have a method called "draw_note" that reacts to different kinds of notes.

I've come across a method called toXML that turns any Java object into an XML node. Not sure how that works. What I want is a way of turning an XML node into another type of object, according to the value of, let's say, of the duration attribute, and then sending it to draw_note. What I would need is a method in Java that would build an object by naming the class - make_object("eighth").

What I'm trying to avoid is a huge "case" structure in which I'm listing all possible variations in the value of the "duration" class each time I want to do something with that node/note.

I hope this makes sense to someone!!!

Jane
Jane Singer
 
Posts: 27
Joined: March, 2014
Reputation: 0

Re: MusicXML and non-DOM data structures

Postby Brian Grainger » Thu Nov 14, 2002 12:18 pm

Jane Singer wrote:I've been trying to come up with a way to incorporate methods that can differentiate between different "types" of nodes in a Dom object built from MusicXML - such as eighth notes, quarter notes. The problem is that XML
(DOM) itself does not do this. They are all just nodes. I would like to have a method called "draw_note" that reacts to different kinds of notes.

There are DOM methods which can differentiate between node types, but these are pre-defined XML node types, such as NODE_ELEMENT, NODE_TEXT, NODE_CDATA_SECTION, etc. It sounds like you want to differentiate between nodes not on their type, but on their value.

Jane Singer wrote:What I'm trying to avoid is a huge "case" structure in which I'm listing all possible variations in the value of the "duration" class each time I want to do something with that node/note.

Do you mean duration attribute? If that's what you're using, how about defining a lookup table, along with an enumerated set of all possible values of your duration attrribute. Preload the lookup table with references to your set of note objects, and then use the value of the duration attribute as an index into the lookup table. This way, all the hard work is done only once during program initialization, rather than each time you have to process a node.

Regards, Brian
Brian Grainger
 
Posts: 111
Joined: March, 2014
Reputation: 0

Re: MusicXML and non-DOM data structures

Postby John Ibbotson » Thu Nov 14, 2002 12:49 pm

Jane, To do this properly, you should look at XML Schema. This allows typed objects to be created in Java from XML documents. However, it does require an XML Schema to be created for MusicXML rather than rely on DTDs. John

Emerging ebusiness Industry Architecture , XML Technology and Messaging, IBM UK Ltd, Hursley Park, Winchester, SO21 2JN

Tel: (work) +44 (0)1962 815188 (home) +44 (0)1722 781271 Fax: +44 (0)1962 816898 Notes Id: John Ibbotson/UK/IBM email:


|---------+---------------------------->
| | "Jane Singer" |
| | .|
| | ac.il> |
| | |
| | 14/11/2002 17:40 |
| | Please respond to|
| | musicxml |
| | |
|---------+---------------------------->
-------------------------------------|
|
|
|
| cc:
|
|
|
|
|
|
-------------------------------------|



I've been trying to come up with a way to incorporate methods that can differentiate between different "types" of nodes in a Dom object built from MusicXML - such as eighth notes, quarter notes. The problem is that XML
(DOM) itself does not do this. They are all just nodes. I would like to have a method called "draw_note" that reacts to different kinds of notes.

I've come across a method called toXML that turns any Java object into an XML node. Not sure how that works. What I want is a way of turning an XML node into another type of object, according to the value of, let's say, of the duration attribute, and then sending it to draw_note. What I would need is a method in Java that would build an object by naming the class - make_object("eighth").

What I'm trying to avoid is a huge "case" structure in which I'm listing all possible variations in the value of the "duration" class each time I want to do something with that node/note.

I hope this makes sense to someone!!!

Jane
John Ibbotson
 
Posts: 4
Joined: March, 2014
Reputation: 0

RE: MusicXML and non-DOM data structures

Postby Michael Good » Thu Nov 14, 2002 1:53 pm

Hi Jane,

I think you will need to do some sort of case-like statement - but on the <type> element, not on the the <duration> element, if possible. There are only 11 possible values for the <type> element, so it shouldn't be too bad. As Brian mentions, pre-computing things for a lookup table should make the code simpler and faster.

As John mentions, an XML schema would provide more type information for the <type> element than our DTD can provide. But XML schemas have other problems for our use, so I think you would want to stay with our standard DTD definition.

Best regards, Michael
Michael Good
VP of MusicXML Technologies
MakeMusic, Inc.
User avatar
Michael Good
 
Posts: 2197
Joined: March, 2014
Reputation: 0

RE: MusicXML and non-DOM data structures

Postby John Ibbotson » Fri Nov 15, 2002 2:18 am

Michael, I'd be interested in what problems you've identified with XML Schema for MusicXML. John

Emerging ebusiness Industry Architecture , XML Technology and Messaging, IBM UK Ltd, Hursley Park, Winchester, SO21 2JN

Tel: (work) +44 (0)1962 815188 (home) +44 (0)1722 781271 Fax: +44 (0)1962 816898 Notes Id: John Ibbotson/UK/IBM email:


|---------+---------------------------->
| | "Michael Good" |
| | <[email protected]|
| | are.com> |
| | |
| | 14/11/2002 19:53 |
| | Please respond to|
| | musicxml |
| | |
|---------+---------------------------->
-------------------------------------|
|
|
|
| cc:
|
|
|
|
|
|
-------------------------------------|



Hi Jane,

I think you will need to do some sort of case-like statement - but on the <type> element, not on the the <duration> element, if possible. There are only 11 possible values for the <type> element, so it shouldn't be too bad. As Brian mentions, pre-computing things for a lookup table should make the code simpler and faster.

As John mentions, an XML schema would provide more type information for the <type> element than our DTD can provide. But XML schemas have other problems for our use, so I think you would want to stay with our standard DTD definition.

Best regards, Michael
John Ibbotson
 
Posts: 4
Joined: March, 2014
Reputation: 0

RE: MusicXML and non-DOM data structures

Postby Michael Good » Tue Nov 19, 2002 6:05 pm

Hi John,

The main problems with XML Schema for use with MusicXML are 1) complexity, 2) lack of external entities, and 3) competition from different schema proposals such as W3C vs. RELAX NG.

When we started MusicXML, schemas were still in development, while DTDs were a stable and widely supported part of XML. Schemas are further along now, but we still don't see the strong-typing advantages outweighing the disadvantages above, combined with the opportunity cost in terms of spending time migrating from a DTD to a schema.

More important for now is to enhance MusicXML's capabilities and support within the music software community. So far, we have not found schemas to really help in either area.

Schemas are a great boon for e-commerce XML applications, but seem to offer much less of an advantage for music applications. Perhaps this will change in the future.

Best regards, Michael
Michael Good
VP of MusicXML Technologies
MakeMusic, Inc.
User avatar
Michael Good
 
Posts: 2197
Joined: March, 2014
Reputation: 0

Re: MusicXML and non-DOM data structures

Postby Murata Makoto » Tue Nov 19, 2002 7:00 pm

Michael Good wrote:Schemas are a great boon for e-commerce XML applications, but seem to offer much less of an advantage for music applications. Perhaps this will change in the future.

Here is a Java program library created from the latest version of MusicXML DTD. This Jar file contains Java source programs as well as Javadoc documents. It is temporarily located at

http://www.asahi-net.or.jp/~eb2m-mrt/musicXMLLibrary.jar

This program is created from a RELAX NG schema, which is created by automatically converting the DTD with dtdInst (James Clark), edited manually for introducing data type information, and then converted to Java by Relaxer.

-- MURATA Makoto (FAMILY Given)
Murata Makoto
 
Posts: 5
Joined: March, 2014
Reputation: 0

RE: MusicXML and non-DOM data structures

Postby Michael Good » Tue Dec 03, 2002 9:35 pm

Dear Murata-san,

My belated thanks for putting together this library! This is something we will be looking at in more detail as we start ramping up on Java-based development here.

Best regards,

Michael Good Recordare LLC


...

Here is a Java program library created from the latest version of MusicXML DTD. This Jar file contains Java source programs as well as Javadoc documents. It is temporarily located at

http://www.asahi-net.or.jp/~eb2m-mrt/musicXMLLibrary.jar

This program is created from a RELAX NG schema, which is created by automatically converting the DTD with dtdInst (James Clark), edited manually for introducing data type information, and then converted to Java by Relaxer.

.
Michael Good
VP of MusicXML Technologies
MakeMusic, Inc.
User avatar
Michael Good
 
Posts: 2197
Joined: March, 2014
Reputation: 0

Who is online

Users browsing this forum: No registered users and 2 guests

cron