Choices

A song must have at least one of ARTIST, COMPOSER, or PRODUCER:

<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">

  <start>
  
    <element name="SONG">
      <element name="TITLE">
        <text/>
      </element>
          
      <oneOrMore>
        <choice>
          <element name="COMPOSER">
            <ref name="personContent"/>
          </element>
          <element name="PRODUCER">
            <ref name="personContent"/>
          </element>
          <element name="ARTIST">
            <text/>
          </element>
        </choice>
      </oneOrMore>
          
      <optional>
        <element name="PUBLISHER">
          <text/>
        </element>
      </optional>
      <optional>
        <element name="LENGTH">
          <text/>
        </element>
      </optional>
      <optional>
        <element name="YEAR">
          <text/>
        </element>
      </optional>
    </element>
    
  </start>

  <define name="personContent">
    <element name="NAME">
      <interleave>
      <element name="GIVEN">
        <text/>
      </element>
      <element name="FAMILY">
        <text/>
      </element>
      </interleave>
    </element>
  </define>

</grammar>

start =
  element SONG {
    element TITLE       { text },
    (element COMPOSER   { personContent }
     | element PRODUCER { personContent }
     | element ARTIST   { text })+,
    element PUBLISHER   { text }?,
    element LENGTH      { text }?,
    element YEAR        { text }?
  }
personContent =
  element NAME {
    element GIVEN    { text }
    & element FAMILY { text }
  }

Previous | Next | Top | Cafe con Leche

Copyright 2005-2007 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified October 29, 2004