C# to MusicXML? [closed]

风流意气都作罢 提交于 2019-12-07 02:26:41

问题


Anyone know of any libraries that can be used to write MusicXML data from C#? Similar to this: http://proxymusic.kenai.com/ (although this one is for java).

I would try to not write it manually, but if worse comes to worst, I will have no choice but to output and write MusicXML manually from my results.


回答1:


Since MusicXML has a XML schema available, you can use xsd.exe to create the classes that represent the XML structure:

xsd /c xlink.xsd musicxml.xsd container.xsd opus.xsd

Then you can use XmlSerializer to load and save the generated classes from/to files.

(For some reason, one of the schema files, osfpvg.xsd, wasn't able to compile correctly. Here's hoping you won't need it.)




回答2:


To use xsd.exe, you can use this command:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\xsd.exe" "c:\dev\musicxml30\musicxml.xsd" "c:\dev\musicxml30\xlink.xsd" "c:\dev\musicxml30\xml.xsd" /c /o:"c:\dev"

Which will create a file called musicxml_xlink_xml.cs in the c:\dev folder.

Compiled Class




回答3:


For me when i tried to convert the MusicXml3.0.xsd, xsd.exe failed everytime. So, what i did was

xsd.exe musicFile.xml 

which generated a schema file, and

xsd.exe musicFile.xsd /classes

which produced the required c# classes. The only thing i had to add in order for the generated xml to be read by programs like Sibelius 7 was to add

<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">

And presto!



来源:https://stackoverflow.com/questions/6567400/c-sharp-to-musicxml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!