History:Development/XML Web Service/Version 1

From MusicBrainz Wiki
Revision as of 01:54, 17 January 2006 by RobertKaye (talk | contribs) (First rev of the proposed schema for the next web service (Imported from MoinMoin))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This page describes the next generation XML based web service for MusicBrainz. Initially we will discuss the proposed XML and its Relax NG schema for expressing MusicBrainz (and music in general) metadata. Once we hammer that out, we'll discuss the URL scheme proposed by Matthias Friedrich.

The following sample XML document describes a partial album:

<?xml version="1.0" encoding="UTF-8"?>
<xm:Metadata xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:xm="http://musicbrainz.org/ns/xm/1/"
             xmlns:az="http://www.amazon.com/gp/aws/landing.html#">
    <xm:albumList>
      <xm:Album id="8f468f36-8c7e-4fc1-9166-50664d267127" type="album">

        <xm:Artist id="8f6bd1e4-fbe1-4f50-aa9b-94c450ec0f11" begin="1991" end="2011">
          <dc:title>Portishead</dc:title>
          <xm:sortName>Portishead</xm:sortName>
        </xm:Artist>

        <dc:title>Dummy</dc:title>
        <xm:counts track="11" cdid="10" trmid="73"/>
        <az:asin>B000001FI7</az:asin>

        <xm:releaseList>
          <xm:release date="1994-10-17" country="us"/>
        </xm:releaseList>

        <xm:cdidList>
           <xm:cdid id="D5LsXhbWwpctL4s5xHSTS_SefQw-"/>
        </xm:cdidList>

        <xm:trackList>
          <xm:Track id="b5d7d380-f43a-4c1f-a5de-694150b093ac" duration="306200">
            <dc:title>Mysterons</dc:title>

            <!-- This block is shown only if the track artist != album artist -->
            <xm:Artist id="8f6bd1e4-fbe1-4f50-aa9b-94c450ec0f11" begin="1991" end="2011" type="group">
              <dc:title>Portishead</dc:title>
              <xm:sortName>Portishead</xm:sortName>
            </xm:Artist>

            <xm:trmidList>
               <xm:trmid id="58bdde9c-9c47-487a-94ae-1e9c4001bd3d"/>
            </xm:trmidList>

          </xm:Track>
        </xm:trackList>

      </xm:Album>
    </xm:albumList>
</xm:Metadata>

The above XML parses and validates with the following Relax NG schema:

<?xml version="1.0" encoding="UTF-8"?>
<!--
   <hr>
   Relax NG Schema for MusicBrainz XML Metadata Version 0, draft 1

   Copyright (c) 2004 Robert Kaye

   The schema is released under the Creative Commons
   Attribution-ShareAlike 2.0 license.

   http://creativecommons.org/licenses/by-sa/2.0/
   <hr>

-->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
         xmlns:xm="http://musicbrainz.org/ns/xm/1/"
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:az="http://www.amazon.com/gp/aws/landing.html#">

   <start>
     <ref name="Metadata"/>
   </start>

   <define name="Metadata">
       <element name="xm:Metadata">
         <optional>
           <ref name="artistList"/>
         </optional>
         <optional>
           <ref name="albumList"/>
         </optional>
         <optional>
           <ref name="trackList"/>
         </optional>
       </element>
   </define>

   <define name="albumList">
       <element name="xm:albumList">
           <oneOrMore>
               <ref name="albumEntity"/>
           </oneOrMore>
       </element>
   </define>

   <define name="artistList">
       <element name="xm:artistList">
           <oneOrMore>
               <ref name="artistEntity"/>
           </oneOrMore>
       </element>
   </define>

   <define name="trackList">
       <element name="xm:trackList">
           <oneOrMore>
             <ref name="trackEntity"/>
           </oneOrMore>
       </element>
   </define>

   <define name="artistEntity">
       <element name="xm:Artist">
           <attribute name="id"/>
           <optional>
               <attribute name="begin"/>
           </optional>
           <optional>
               <attribute name="end"/>
           </optional>
           <optional>
               <attribute name="group"/>
           </optional>
           <optional>
               <attribute name="type"/>
           </optional>

           <element name="dc:title">
               <text/>
           </element>

           <optional>
               <element name="xm:sortName">
                   <text/>
               </element>
           </optional>
       </element>
   </define>

   <define name="albumEntity">

       <element name="xm:Album">
           <attribute name="id"/>
           <optional>
               <attribute name="type"/>
           </optional>
           <optional>
               <attribute name="status"/>
           </optional>

           <ref name="artistEntity"/>

           <element name="dc:title">
               <text/>
           </element>
           <element name="xm:counts">
               <optional>
                   <attribute name="track"/>
               </optional>
               <optional>
                   <attribute name="cdid"/>
               </optional>
               <optional>
                   <attribute name="trmid"/>
               </optional>
               <text/>
           </element>
           <element name="az:asin">
               <text/>
           </element>
           <zeroOrMore>
             <ref name="releaseList"/>
           </zeroOrMore>
           <zeroOrMore>
             <ref name="cdidList"/>
           </zeroOrMore>
           <optional>
             <ref name="trackList"/>
           </optional>

       </element>
   </define>

   <define name="trackEntity">
       <element name="xm:Track">
           <attribute name="id"/>
           <optional>
             <attribute name="duration"/>
           </optional>

           <element name="dc:title">
               <text/>
           </element>
           <optional>
             <ref name="artistEntity"/>
           </optional>
           <optional>
             <ref name="trmidList"/>
           </optional>
       </element>
   </define>

   <define name="releaseList">
       <element name="xm:releaseList">
           <element name="xm:release">
           <optional>
               <attribute name="date"/>
           </optional>
           <optional>
               <attribute name="country"/>
           </optional>
           </element>
       </element>
   </define>

   <define name="cdidList">
       <element name="xm:cdidList">
           <element name="xm:cdid">
               <attribute name="id"/>
           </element>
       </element>
   </define>

   <define name="trmidList">
       <element name="xm:trmidList">
           <element name="xm:trmid">
               <attribute name="id"/>
           </element>
       </element>
   </define>

</grammar>