container.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:annotation>
        <xs:documentation>MusicXML Container W3C XML schema (XSD)

Version 4.0

Copyright © 2004-2021 the Contributors to the MusicXML Specification, published by the W3C Music Notation Community Group under the W3C Community Final Specification Agreement (FSA):

    https://www.w3.org/community/about/agreements/final/

A human-readable summary is available:

    https://www.w3.org/community/about/agreements/fsa-deed/

This is the W3C XML Schema (XSD) version of the MusicXML 4.0 format. Validation is tightened by moving MusicXML definitions from comments into schema data types and definitions. Character entities and other entity usages that are not supported in W3C XML Schema have also been removed. However, the features of W3C XML Schema make it easier to define variations of the MusicXML format, either via extension or restriction.

Starting with Version 2.0, the MusicXML format includes a standard zip compressed version. These zip files can contain multiple MusicXML files as well as other media files for images and sound. The container XSD describes the contents of the META-INF/container.xml file. The 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 MusicXML 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:

    http://www.info-zip.org/doc/appnote-19970311-iz.zip

The JAR file format is specified at:

    https://docs.oracle.com/javase/8/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:

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

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

The first file in the zip container should be a file named mimetype. The contents of this file should be the MIME media type string 

    application/vnd.recordare.musicxml

encoded in US-ASCII. The mimetype file must not be compressed or encrypted, and there must not be an extra field in its zip header. The contents of the mimetype file must not contain any leading padding or white space and must not begin with a byte order mark. Older versions of MusicXML did not specify this mimetype file, so applications may see containers without a mimetype file.

The recommended file extension for compressed MusicXML files is .mxl. The recommended file extension for uncompressed MusicXML files is .musicxml. Older versions of MusicXML use .xml as the extension for uncompressed MusicXML files, so it is recommended that applications be prepared to read files with the .xml extension as well.

It is recommended that applications that run on macOS and iOS use the following Uniform Type Identifier for MusicXML files:
            
    <array>
        <dict>
            <key>UTTypeIdentifier</key>
            <string>com.recordare.musicxml.uncompressed</string>
            <key>UTTypeReferenceURL</key>
            <string>http://www.musicxml.org/</string>
            <key>UTTypeDescription</key>
            <string>MusicXML File</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>musicxml</string>
                </array>
                <key>public.mime-type</key>
                <array>
                    <string>application/vnd.recordare.musicxml+xml</string>
                </array>
            </dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.xml</string>
            </array>
        </dict>
        <dict>
            <key>UTTypeIdentifier</key>
            <string>com.recordare.musicxml</string>
            <key>UTTypeReferenceURL</key>
            <string>http://www.musicxml.org/</string>
            <key>UTTypeDescription</key>
            <string>MusicXML File</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>mxl</string>
                </array>
                <key>public.mime-type</key>
                <array>
                    <string>application/vnd.recordare.musicxml</string>
                </array>
            </dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.zip-archive</string>
            </array>
        </dict>
    </array>

The XML catalog at catalog.xml supports validating against a local copy of this XSD rather than the networked version. Software often has trouble using system IDs due to factors such as restrictions on network access, or resources having moved from the original specified location. To validate with the MusicXML XSD, use a schema URI of "http://www.musicxml.org/xsd/sounds.xsd".</xs:documentation>
    </xs:annotation>
    
    <!-- Complex types -->
    
    <xs:complexType name="container">
        <xs:annotation>
            <xs:documentation>The container type is used for the root element of a MusicXML sounds file. It contains a single rootfiles elements.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="rootfiles" type="rootfiles"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="rootfiles">
        <xs:annotation>
            <xs:documentation>The rootfiles element includes the starting points for the different representations of a MusicXML score. The MusicXML root must be described in the first rootfile element. Additional rootfile elements can describe alternate versions such as PDF and audio files.

When a MusicXML file contains both a score file and separate files for individual parts, the score file is the one that is referenced in the first rootfile element. The part files can be linked from within the score file and need not be listed here.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="rootfile" type="rootfile" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="rootfile">
        <xs:annotation>
            <xs:documentation>The rootfile element describes each top-level file in the MusicXML container. A MusicXML file used as a rootfile may have score-partwise, score-timewise, or opus as its document element.

The required full-path attribute provides the path relative to the root folder of the zip file. The optional media-type attribute identifies the media type of different top-level root files. It is an error to have a non-MusicXML media-type value in the first rootfile in a rootfiles element. If no media-type value is present, a MusicXML file is assumed.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="full-path" type="xs:token" use="required"/>
        <xs:attribute name="media-type" type="xs:token"/>
    </xs:complexType>
    
    <!-- Global element that is the root for MusicXML opus files -->
    
    <xs:element name="container" type="container" block="extension substitution" final="#all">
        <xs:annotation>
            <xs:documentation>The container element with a container type is the root element of the META-INF/container.xml file.</xs:documentation>
        </xs:annotation>
    </xs:element>
</xs:schema>