<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sch="http://www.ascc.net/xml/schematron" version="1.0">
   <axsl:template match="*|@*" mode="schematron-get-full-path">
      <axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
      <axsl:text>/</axsl:text>
      <axsl:if test="count(. | ../@*) = count(../@*)">@</axsl:if>
      <axsl:value-of select="name()"/>
      <axsl:text>[</axsl:text>
      <axsl:value-of select="1+count(preceding-sibling::*[name()=name(current())])"/>
      <axsl:text>]</axsl:text>
   </axsl:template>
   <axsl:template match="/">
      <axsl:apply-templates select="/" mode="M1"/>
      <axsl:apply-templates select="/" mode="M2"/>
      <axsl:apply-templates select="/" mode="M3"/>
      <axsl:apply-templates select="/" mode="M4"/>
      <axsl:apply-templates select="/" mode="M5"/>
   </axsl:template>
   <axsl:template match="/" priority="4000" mode="M1">
      <axsl:choose>
         <axsl:when test="count(tracklist) = 1"/>
         <axsl:otherwise>Document must contain exactly one tracklist.</axsl:otherwise>
      </axsl:choose>
      <axsl:apply-templates mode="M1"/>
   </axsl:template>
   <axsl:template match="tracklist" priority="3999" mode="M1">
      <axsl:if test=".">Tracklist:</axsl:if>
      <axsl:choose>
         <axsl:when test="count(track) &gt; 1"/>
         <axsl:otherwise>Tracklist must contain at least one track.</axsl:otherwise>
      </axsl:choose>
      <axsl:apply-templates mode="M1"/>
   </axsl:template>
   <axsl:template match="track" priority="3998" mode="M1">
      <axsl:if test=".">
         <axsl:text xml:space="preserve"> </axsl:text><axsl:value-of select="length"/><axsl:text xml:space="preserve"> </axsl:text>:<axsl:text xml:space="preserve"> </axsl:text><axsl:value-of select="name"/><axsl:text xml:space="preserve"> </axsl:text></axsl:if>
      <axsl:apply-templates mode="M1"/>
   </axsl:template>
   <axsl:template match="text()" priority="-1" mode="M1"/>
   <axsl:template match="desc" priority="4000" mode="M2">
      <axsl:choose>
         <axsl:when test="count(topicref[@TID = ../../@TID])"/>
         <axsl:otherwise>description must mention the described topic</axsl:otherwise>
      </axsl:choose>
      <axsl:apply-templates mode="M2"/>
   </axsl:template>
   <axsl:template match="text()" priority="-1" mode="M2"/>
   <axsl:template match="album | interpret | company" priority="4000" mode="M3">
      <axsl:choose>
         <axsl:when test="@id"/>
         <axsl:otherwise>Elements of type &lt;name /&gt; should have a unique 'id' attribute</axsl:otherwise>
      </axsl:choose>
      <axsl:apply-templates mode="M3"/>
   </axsl:template>
   <axsl:template match="text()" priority="-1" mode="M3"/>
   <axsl:template match="track_refs" priority="4000" mode="M4">
      <axsl:choose>
         <axsl:when test="id(@album_ref)"/>
         <axsl:otherwise>An element of type<axsl:text xml:space="preserve"> </axsl:text><axsl:value-of select="name(.)"/><axsl:text xml:space="preserve"> </axsl:text>should have an 'album_ref' attribute that should contain a unique identifier.</axsl:otherwise>
      </axsl:choose>
      <axsl:choose>
         <axsl:when test="id(@interpret_ref)"/>
         <axsl:otherwise>An element of type<axsl:text xml:space="preserve"> </axsl:text><axsl:value-of select="name(.)"/><axsl:text xml:space="preserve"> </axsl:text>should have an interpret_ref attribute that should contain a unique identifier.</axsl:otherwise>
      </axsl:choose>
      <axsl:apply-templates mode="M4"/>
   </axsl:template>
   <axsl:template match="album" priority="3999" mode="M4">
      <axsl:choose>
         <axsl:when test="id(@company_ref)"/>
         <axsl:otherwise>An element of type<axsl:text xml:space="preserve"> </axsl:text><axsl:value-of select="name(.)"/><axsl:text xml:space="preserve"> </axsl:text>should have a company_ref attribute that should contain a unique identifier.</axsl:otherwise>
      </axsl:choose>
      <axsl:apply-templates mode="M4"/>
   </axsl:template>
   <axsl:template match="text()" priority="-1" mode="M4"/>
   <axsl:template match="band" priority="4000" mode="M5">
      <axsl:choose>
         <axsl:when test="count(person) &gt; 1"/>
         <axsl:otherwise>A band must have more than one person, use soloartist instead.</axsl:otherwise>
      </axsl:choose>
      <axsl:choose>
         <axsl:when test="count(name) = 1"/>
         <axsl:otherwise>A band must have exactly one name.</axsl:otherwise>
      </axsl:choose>
      <axsl:apply-templates mode="M5"/>
   </axsl:template>
   <axsl:template match="text()" priority="-1" mode="M5"/>
   <axsl:template match="text()" priority="-1"/>
</axsl:stylesheet>
