MakeMusic
SmartMusic Finale Garritan MusicXML

Properly referencing the xsd in a document (supernoob)

Moderator: Michael Good

Properly referencing the xsd in a document (supernoob)

Postby Matthew.James.Briggs » Sat Sep 06, 2014 12:23 pm

A few months ago when beginning this difficult learning process, I chose to learn xml schema instead of dtd since xml schema is more precise. Now I'm discovering that Finale exports xml files that reference the dtd and all of the examples on the musicxml site reference the dtd. So I'm having trouble finding an example of an xml document that references musicxml.xsd.

So I took this document and converted the first few lines:

FROM:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.0">


TO:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<score-partwise version="3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.musicxml.org/xsd/musicxml.xsd">


I am experimenting with on-the-fly-parsing xml editor "Xmplify" and the program seems to understand my xsd reference and parses the document based on musicxml.xsd.

My question: have I referenced the musicxml.xsd in the manner that is idiomatically correct? If not can you show my a better syntax for this?

Side question: "http://www.musicxml.org/xsd/musicxml.xsd" appears to immediately redirect to this "http://www.musicxml.com/xsd/musicxml.xsd". Which is correct?

Unrelated FYI: Xmplify throws a warning on the musicxml.xsd schema:
Code: Select all
Line:    3099
Kind: Schema Validation Warning
Details: Element '{http://www.w3.org/2001/XMLSchema}complexType': The content model is not deterministic.
“Now that things are so simple, there's so much to do.” - Morton Feldman
http://matthewjamesbriggs.com
User avatar
Matthew.James.Briggs
 
Posts: 23
Joined: May, 2014
Location: Seattle, WA, USA
Reputation: 0
Software Owned:
Max OS X, Finale, Logic Pro, XCode, Xmplify, Sublime Text

Re: Properly referencing the xsd in a document (supernoob)

Postby Matthew.James.Briggs » Fri Sep 12, 2014 2:24 am

Hmmm, bad questions or dead site? I read that dolet plugin can be set to reference the xsd, so perhaps I can export a file from finale using the dolet plugin, telling it to reference xsd and see how it does this in its output. I haven't tried this yet though.
“Now that things are so simple, there's so much to do.” - Morton Feldman
http://matthewjamesbriggs.com
User avatar
Matthew.James.Briggs
 
Posts: 23
Joined: May, 2014
Location: Seattle, WA, USA
Reputation: 0
Software Owned:
Max OS X, Finale, Logic Pro, XCode, Xmplify, Sublime Text

Re: Properly referencing the xsd in a document (supernoob)

Postby Michael Good » Mon Sep 15, 2014 10:21 am

Hi Matthew,

Sorry for the delay in replying. I would recommend following the pattern that is in the examples with the DTD references. In general you don't want to rely on the network version of either the XSD or DTD for validation; instead you want to use an entity resolver. The entity resolver can take the public identifier "-//Recordare//DTD MusicXML 3.0 Partwise//EN" and use it to read a local copy of the XSD or DTD, rather than the URL that is in the system ID.

This works with validation using either the XSD or DTD. Using xsi:noNamespaceSchemaLocation will fail with DTD validation because that attribute isn't declared in the DTD.
Michael Good
VP of MusicXML Technologies
MakeMusic, Inc.
User avatar
Michael Good
 
Posts: 2197
Joined: March, 2014
Reputation: 0

Re: Properly referencing the xsd in a document (supernoob)

Postby .mjb » Thu Apr 23, 2015 9:20 am

Following up on this as I still am having a hard time finding an example.

Can someone post a version of this
http://www.musicxml.com/tutorial/hello-world/
but replace the beginning so that the document references the xsd instead of the dtd?

Michael, I appreciate your help. I just need to see this done once and I'll be good to go. I can't find an example of a MusicXML document that does this.
User avatar
.mjb
 
Posts: 15
Joined: March, 2014
Location: Seattle, WA, USA
Reputation: 0
Software Owned:
Finale 2014, Logic Pro X, Mac 10.9.5, Xcode, Xmplify

Re: Properly referencing the xsd in a document (supernoob)

Postby .mjb » Thu Apr 23, 2015 12:26 pm

I may be understanding Michael's answer. Perhaps the answer is that there is no way for the XML document itself to state that it prefers XSD Validation?
User avatar
.mjb
 
Posts: 15
Joined: March, 2014
Location: Seattle, WA, USA
Reputation: 0
Software Owned:
Finale 2014, Logic Pro X, Mac 10.9.5, Xcode, Xmplify

Re: Properly referencing the xsd in a document (supernoob)

Postby Michael Good » Thu Apr 23, 2015 2:44 pm

Right, there is no way in MusicXML 3.0 to state a preference for XSD validation that doesn't cause validation issues when using the DTD. This is something we could change in a future version of MusicXML if there is enough interest.
Michael Good
VP of MusicXML Technologies
MakeMusic, Inc.
User avatar
Michael Good
 
Posts: 2197
Joined: March, 2014
Reputation: 0

Re: Properly referencing the xsd in a document (supernoob)

Postby .mjb » Fri Apr 24, 2015 9:14 am

Thank you, Michael. I understand this better now. Reading this back the way I understand it:

DTD-validated MusicXML syntax is a superset of XSD-validated MusicXML syntax. The norm is for applications to validate using the DTD and because of the discrepancy between the two specifications, applications should allow for DTD-validated syntax.

Is there anything that one can do musically/semantically with DTD-validated syntax which cannot be done with XSD-validated syntax? Or is the difference that XSD-validated syntax prevents one from writing MusicXML that one shouldn't write?

As a side-note, my C++ class library now represents 100% of the XSD specification. Here is a sample program which produces the Hello World MusicXML. Turns out that, by staying extremely close to the XSD specification my class library requires very verbose syntax. So the next phase of my development will be to write some abstractions (builders) that make it easier to construct MusicXML documents while implementing the class library.

Code: Select all
 <iostream>
 "DocumentPartwise.h"
 "Elements.h"

using namespace mx::e;
using namespace mx::d;
using namespace mx::types;
using namespace std;

int main(int argc, const char * argv[])
{
    auto doc = makeDocumentPartwise();
    auto s = doc->getScorePartwise();
    s->getAttributes()->hasVersion = true;
    s->getAttributes()->version = XsToken( "3.0" );
    auto header = s->getScoreHeaderGroup();
    header->getPartList()->getScorePart()->getAttributes()->id = XsID( "P1" );
    header->getPartList()->getScorePart()->getPartName()->setValue( XsString( "Music" ) );
    auto part = *( s->getPartwisePartSet().cbegin() );
    part->getAttributes()->id = XsIDREF( "P1" );
    auto measure = *( part->getPartwiseMeasureSet().cbegin() );
    measure->getAttributes()->number = XsToken( "1" );
    auto propertiesChoice = makeMusicDataChoice();
    propertiesChoice->setChoice( MusicDataChoice::Choice::properties );
    auto properties = propertiesChoice->getProperties();
    properties->setHasDivisions( true );
    properties->getDivisions()->setValue( PositiveDivisionsValue( 1 ) );
    properties->addKey( makeKey() );
    auto time = makeTime();
    time->getTimeChoice()->setChoice( TimeChoice::Choice::timeSignature );
    time->getTimeChoice()->getTimeSignature()->getBeats()->setValue( XsString( "4" ) );
    time->getTimeChoice()->getTimeSignature()->getBeatType()->setValue( XsString( "4" ) );
    properties->addTime( time );
    auto clef = makeClef();
    clef->getSign()->setValue( ClefSign::g );
    clef->setHasLine( true );
    clef->getLine()->setValue( StaffLine( 2 ) );
    properties->addClef( clef );
    measure->getMusicDataGroup()->addMusicDataChoice( propertiesChoice );
    auto noteData = makeMusicDataChoice();
    noteData->setChoice( MusicDataChoice::Choice::note );
    noteData->getNote()->getNoteChoice()->setChoice( NoteChoice::Choice::normal );
    noteData->getNote()->getNoteChoice()->getNormalNoteGroup()->getFullNoteGroup()->getFullNoteTypeChoice()->setChoice( FullNoteTypeChoice::Choice::pitch );
    noteData->getNote()->getNoteChoice()->getNormalNoteGroup()->getFullNoteGroup()->getFullNoteTypeChoice()->getPitch()->getStep()->setValue( StepEnum::c );
    noteData->getNote()->getNoteChoice()->getNormalNoteGroup()->getFullNoteGroup()->getFullNoteTypeChoice()->getPitch()->getOctave()->setValue( OctaveValue( 4 ) );
    noteData->getNote()->getNoteChoice()->getNormalNoteGroup()->getDuration()->setValue( PositiveDivisionsValue( 4 ) );
    noteData->getNote()->getType()->setValue( NoteTypeValue::whole );
    measure->getMusicDataGroup()->addMusicDataChoice( noteData );
   
    doc->toStream( cout ); /* print Hello World MusicXML document to console */
    return 0;
}
User avatar
.mjb
 
Posts: 15
Joined: March, 2014
Location: Seattle, WA, USA
Reputation: 0
Software Owned:
Finale 2014, Logic Pro X, Mac 10.9.5, Xcode, Xmplify

Re: Properly referencing the xsd in a document (supernoob)

Postby Michael Good » Fri Apr 24, 2015 11:11 am

I think more applications validate against the XSD than the DTD these days, especially newer applications. But there are enough applications validating against the DTD that writing applications should support both. And yes, the XSD validated syntax warns about writing MusicXML that one shouldn't write - it is a tighter, more accurate specification than the DTD.

Finale currently validates against the DTD because the error messages from the Xerces Java parser were more helpful there than for the XSD. The XSD error messages seem to have improved, so we may change that in a future Finale release. The Dolet plug-in allows validation in Finale against either the DTD or the XSD.
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: Baidu [Spider] and 2 guests