History:Development/XML Web Service/Version 1: Difference between revisions

From MusicBrainz Wiki
Jump to navigationJump to search
(First rev of the proposed schema for the next web service (Imported from MoinMoin))
 
(Changed the namespace to xm and used all lowercase element names (Imported from MoinMoin))
Line 2: Line 2:


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


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


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


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


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


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


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


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


</xm:Track>
</mb:track>
</xm:trackList>
</mb:track-list>


</xm:Album>
</mb:album>
</xm:albumList>
</mb:album-list>
</xm:Metadata>
</mb:metadata>
</pre>
</pre>


Line 55: Line 55:


Copyright (c) 2004 Robert Kaye
Copyright (c) 2004 Robert Kaye

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


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


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


<define name="Metadata">
<define name="metadata">
<element name="xm:Metadata">
<element name="mb:metadata">
<optional>
<optional>
<ref name="artistList"/>
<ref name="artist-list"/>
</optional>
</optional>
<optional>
<optional>
<ref name="albumList"/>
<ref name="album-list"/>
</optional>
</optional>
<optional>
<optional>
<ref name="trackList"/>
<ref name="track-list"/>
</optional>
</optional>
</element>
</element>
</define>
</define>


<define name="albumList">
<define name="album-list">
<element name="xm:albumList">
<element name="mb:album-list">
<oneOrMore>
<oneOrMore>
<ref name="albumEntity"/>
<ref name="album-entity"/>
</oneOrMore>
</oneOrMore>
</element>
</element>
</define>
</define>


<define name="artistList">
<define name="artist-list">
<element name="xm:artistList">
<element name="mb:artist-list">
<oneOrMore>
<oneOrMore>
<ref name="artistEntity"/>
<ref name="artist-entity"/>
</oneOrMore>
</oneOrMore>
</element>
</element>
</define>
</define>


<define name="trackList">
<define name="track-list">
<element name="xm:trackList">
<element name="mb:track-list">
<oneOrMore>
<oneOrMore>
<ref name="trackEntity"/>
<ref name="track-entity"/>
</oneOrMore>
</oneOrMore>
</element>
</element>
</define>
</define>


<define name="artistEntity">
<define name="artist-entity">
<element name="xm:Artist">
<element name="mb:artist">
<attribute name="id"/>
<attribute name="id"/>
<optional>
<optional>
Line 132: Line 132:


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


<define name="albumEntity">
<define name="album-entity">


<element name="xm:Album">
<element name="mb:album">
<attribute name="id"/>
<attribute name="id"/>
<optional>
<optional>
Line 150: Line 150:
</optional>
</optional>


<ref name="artistEntity"/>
<ref name="artist-entity"/>


<element name="dc:title">
<element name="dc:title">
<text/>
<text/>
</element>
</element>
<element name="xm:counts">
<element name="mb:counts">
<optional>
<optional>
<attribute name="track"/>
<attribute name="track"/>
Line 171: Line 171:
</element>
</element>
<zeroOrMore>
<zeroOrMore>
<ref name="releaseList"/>
<ref name="release-list"/>
</zeroOrMore>
</zeroOrMore>
<zeroOrMore>
<zeroOrMore>
<ref name="cdidList"/>
<ref name="cdid-list"/>
</zeroOrMore>
</zeroOrMore>
<optional>
<optional>
<ref name="trackList"/>
<ref name="track-list"/>
</optional>
</optional>


Line 183: Line 183:
</define>
</define>


<define name="trackEntity">
<define name="track-entity">
<element name="xm:Track">
<element name="mb:track">
<attribute name="id"/>
<attribute name="id"/>
<optional>
<optional>
Line 194: Line 194:
</element>
</element>
<optional>
<optional>
<ref name="artistEntity"/>
<ref name="artist-entity"/>
</optional>
</optional>
<optional>
<optional>
<ref name="trmidList"/>
<ref name="trmid-list"/>
</optional>
</optional>
</element>
</element>
</define>
</define>


<define name="releaseList">
<define name="release-list">
<element name="xm:releaseList">
<element name="mb:release-list">
<element name="xm:release">
<element name="mb:release">
<optional>
<optional>
<attribute name="date"/>
<attribute name="date"/>
Line 215: Line 215:
</define>
</define>


<define name="cdidList">
<define name="cdid-list">
<element name="xm:cdidList">
<element name="mb:cdid-list">
<element name="xm:cdid">
<element name="mb:cdid">
<attribute name="id"/>
<attribute name="id"/>
</element>
</element>
Line 223: Line 223:
</define>
</define>


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

Revision as of 20:24, 17 January 2006

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"?>
<mb:metadata xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:mb="http://musicbrainz.org/ns/mb/1/"
             xmlns:az="http://www.amazon.com/gp/aws/landing.html#">
    <mb:album-list>
      <mb:album id="8f468f36-8c7e-4fc1-9166-50664d267127" type="album">

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

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

        <mb:release-list>
          <mb:release date="1994-10-17" country="us"/>
        </mb:release-list>

        <mb:cdid-list>
           <mb:cdid id="D5LsXhbWwpctL4s5xHSTS_SefQw-"/>
        </mb:cdid-list>

        <mb:track-list>
          <mb: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 -->
            <mb:artist id="8f6bd1e4-fbe1-4f50-aa9b-94c450ec0f11" begin="1991" end="2011" type="group">
              <dc:title>Portishead</dc:title>
              <mb:sortName>Portishead</mb:sortName>
            </mb:artist>

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

          </mb:track>
        </mb:track-list>

      </mb:album>
    </mb:album-list>
</mb: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:mb="http://musicbrainz.org/ns/mb/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="mb:metadata">
         <optional>
           <ref name="artist-list"/>
         </optional>
         <optional>
           <ref name="album-list"/>
         </optional>
         <optional>
           <ref name="track-list"/>
         </optional>
       </element>
   </define>

   <define name="album-list">
       <element name="mb:album-list">
           <oneOrMore>
               <ref name="album-entity"/>
           </oneOrMore>
       </element>
   </define>

   <define name="artist-list">
       <element name="mb:artist-list">
           <oneOrMore>
               <ref name="artist-entity"/>
           </oneOrMore>
       </element>
   </define>

   <define name="track-list">
       <element name="mb:track-list">
           <oneOrMore>
             <ref name="track-entity"/>
           </oneOrMore>
       </element>
   </define>

   <define name="artist-entity">
       <element name="mb: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="mb:sortName">
                   <text/>
               </element>
           </optional>
       </element>
   </define>

   <define name="album-entity">

       <element name="mb:album">
           <attribute name="id"/>
           <optional>
               <attribute name="type"/>
           </optional>
           <optional>
               <attribute name="status"/>
           </optional>

           <ref name="artist-entity"/>

           <element name="dc:title">
               <text/>
           </element>
           <element name="mb: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="release-list"/>
           </zeroOrMore>
           <zeroOrMore>
             <ref name="cdid-list"/>
           </zeroOrMore>
           <optional>
             <ref name="track-list"/>
           </optional>

       </element>
   </define>

   <define name="track-entity">
       <element name="mb:track">
           <attribute name="id"/>
           <optional>
             <attribute name="duration"/>
           </optional>

           <element name="dc:title">
               <text/>
           </element>
           <optional>
             <ref name="artist-entity"/>
           </optional>
           <optional>
             <ref name="trmid-list"/>
           </optional>
       </element>
   </define>

   <define name="release-list">
       <element name="mb:release-list">
           <element name="mb:release">
           <optional>
               <attribute name="date"/>
           </optional>
           <optional>
               <attribute name="country"/>
           </optional>
           </element>
       </element>
   </define>

   <define name="cdid-list">
       <element name="mb:cdid-list">
           <element name="mb:cdid">
               <attribute name="id"/>
           </element>
       </element>
   </define>

   <define name="trmid-list">
       <element name="mb:trmid-list">
           <element name="mb:trmid">
               <attribute name="id"/>
           </element>
       </element>
   </define>

</grammar>