Excerpt from XSLT 2.0 Programmer's Reference, Third Edition:
A Scenario: Transforming Music
As an indication of how far XML has now penetrated, Robin Cover's index of XML-based application standards at http://xml.coverpages.org/xmlApplications.html
today runs to over 580 entries. (The last one is entitled Mind Reading Markup Language, but as far as I can tell, all the other entries are serious.)
I'll follow just one of these 580 lines, XML and Music, which takes us to http://xml.coverpages.org/xmlMusic.html. On this page we find a list of no less than 17 standards, proposals, or initiatives that use XML for marking up music.
Some of this diversity is unnecessary, and many of these initiatives will bear little fruit. Even the names of the standards are chaotic: there is a Music Markup Language, a MusicML, a MusicXML, and a MusiXML, all of which appear to be quite unrelated. There are at least two really serious contenders: the Music Encoding Initiative (MEI) and the Standard Music Description Language (SMDL). The MEI derives its inspiration from the Text Encoding Initiative, which is widely used by the library community for creating digital text archives, while SMDL is related to the HyTime hypermedia standards and takes into account requirements such as the need to synchronize music with video or with a lighting script.
The diversity of standards is inevitable before the industry can come up with a standard that works for everyone. Without variety, there can be no innovation or experimentation. In fact, the likely outcome is not a single standard, but a collection of three or four different standards that are optimized for different needs. The different notations were invented with different purposes in mind: a markup language used by a publisher for printing sheet music has different requirements from the one designed to let you listen to the music from a browser.
For most of us, music may be fun, a diversion from the world of work. But for others, it is a very serious billion-dollar business. Standards that make information interchange in this business easier have an enormous economic impact. Whether you're interested in the music or the money, we're not dealing here with something that's trivial. So it shouldn't be surprising that so much effort is going into the process of creating standards in this area.
In earlier editions of this book I introduced the idea of using XSLT to transform music as a theoretical possibility, something to make my readers think about the range of possibilities open for the language. Today, it is no longer a theoretical possibility -- people are actually doing it.
With 17 different schemas for music in existence, all with different strengths and weaknesses (and fan clubs), there is a big need to convert information from one of these formats to any of the others. There is also a need to convert information from any of these formats to a printable score or an audible performance of the music, as well as a need to create XML representations of music from non-XML sources such as MIDI files. XSLT has a role to play in all of these conversions.
So you could use XSLT to:
- Convert music from one of these representations to another, for example, from MEI to SMDL.
- Convert music from any of these representations into visual music notation, by generating the XML-based vector graphics format SVG.
- Play the music on a synthesizer, by generating a MIDI (Musical Instrument Digital Interface) file.
- Perform a musical transformation, such as transposing the music into a different key or extracting parts for different instruments or voices.
- Extract the lyrics, into HTML or into a text-only XML document.
- Capture music from non-XML formats and translate it into XML (XSLT 2.0 is especially useful here).
As you can see, XSLT is not just for converting XML documents to HTML.
For some real examples of XSLT stylesheets used to transform music, take a look at a thesis written by Baron Schwartz at the University of Virginia (http://www.cs.virginia.edu/~bps7j/thesis/).
Contact: