Recordare Main Navigation Menu Recordare

Compressed .MXL Files


Regular, plain text MusicXML files can be very large - much larger than the original Finale and Sibelius files, or corresponding MIDI files. This was not a big problem for using MusicXML as an interchange format, but it inhibited MusicXML’s use as a sheet music distribution format.

MusicXML 2.0 introduces a new compressed format which reduces MusicXML file sizes to roughly the same size as the corresponding MIDI files. The format uses zip compression and a special .mxl file suffix and Internet media type to identify files as MusicXML files vs. generic XML files. This section describes how the compressed format works.

Compressed File Format

MusicXML uses a zip-based XML format similar to that used by Open Office and many other XML formats. The MusicXML 2.0 zip file format is compatible with the zip format used by the java.util.zip package and Java JAR files. It is based on the Info-ZIP format described at:

ftp://ftp.uu.net/pub/archiving/zip/doc/appnote-970311-iz.zip

The JAR file format is specified at:

http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html

Note that, compatible with JAR files, file names should be encoded in UTF-8 format. Files with the zip container are compressed the DEFLATE algorithm. The DEFLATE Compressed Data Format (RFC 1951) is specified at:

http://www.ietf.org/rfc/rfc1951.txt

By making these choices, software can usually use the zip libraries available for Java and most other programming languages to create the compressed zip files.

File Suffixes and Media Types

The recommended file suffix for compressed MusicXML files is .mxl. Using a unique file suffix lets programs distinguish MusicXML files from generic XML files in a way that using the .xml suffix for uncompressed files does not. As an example, Myriad’s QuickLook plug-in for Mac OS 10.5 relies on the .mxl suffix to indicate that it should provide a preview of the score image in the Mac Finder application.

Many XML editing tools such as XMLSpy and Oxygen now support the editing of zip-compressed XML files. All that is necessary is to let the editor application know that .mxl files are a zip-based format. The editor will then let you edit both the structure of the .mxl file as well as the .xml files that are contained within the zip archive.

For Internet use, MusicXML 2.0 has registered media types available for both compressed .mxl and uncompressed .xml files. The recommended media type for a compressed MusicXML file is:

application/vnd.recordare.musicxml

The recommended media type for an uncompressed MusicXML file is:

application/vnd.recordare.musicxml+xml

Zip Archive Structure

Following the example of many zip-based XML formats, MusicXML has a strictly defined way to determine where the root MusicXML file is within an archive. Each MusicXML zip archive has a file located at META-INF/container.xml. This container describes the starting point for the MusicXML version of the file, as well as alternate renditions such as PDF and audio versions of the musical score.

The container.xml file is defined by the container.dtd file. Given the simplicity of the format, there is no corresponding .xsd file at this time. As an example, let us look at the Elite Syncopations .MXL file available on the Recordare web site. Here is its META-INF/container.xml file:

<?xml version="1.0" encoding="UTF-8">
<container>
  <rootfiles>
    <rootfile full-path="elite.xml"/>
  </rootfiles>
</container>

The container element is the document element for this file. It contains a single rootfiles element. The rootfiles element in turn contains one or more rootfile elements. The MusicXML root must be described in the first rootfile element. The full-path attribute provides the path relative to the root folder of the zip file. A MusicXML file used as a rootfile may have score-partwise, score-timewise, or opus as its document element.

Additional rootfile elements can describe alternate versions such as PDF and audio files. Multiple rootfile elements can be distinguished by each one having a different media-type attribute value. For instance, if the elite.mxl file contained a PDF rendition as well as the MusicXML file, the container.xml file would look like this:

<?xml version="1.0" encoding="UTF-8">
<container>
  <rootfiles>
    <rootfile full-path="elite.xml"
              media-type="application/vnd.recordare.musicxml+xml"/>
    <rootfile full-path="elite.pdf"
              media-type="application/pdf"/>
  </rootfiles>
</container>

If no media-type value is present, a MusicXML file is assumed. However, if multiple rootfiles are present, it will probably make things more clear to include the media-type attribute for all rootfile elements.

The zip archive can also include images that are referenced with the MusicXML image and credit-image elements, or other media that are referenced using the MusicXML link element. MusicXML 2.0 does not specify where these files need to be located in the zip file, but it is probably least confusing if images or other files of a similar type are grouped together in a subfolder within the zip archive.


FAQ - Hello World - File Structure - MIDI-Compatible - Notation Basics - Chord Symbols - Tablature - Percussion - .MXL Files

Home - Music - Software - MusicXML - Tutorial - Events - Search - Store - About Us

Copyright © 2008 Recordare LLC.

Last updated September 26, 2008.