RE: Update: Pronunciation Lexicon spec, possible schema.

 

    -----Original Message-----
    From: Max Froumentin
    > I posted a candidate schema matching the grammar outlined 
    in the spec.
    
    Interesting idea...
    But it didn't come out right in your email. See:
    http://lists.w3.org/Archives/Public/www-voice/2005JanMar/0030.html

Sorry. Unsure why, possibly the pgp signature.
schema within the message below.
  It ISO/IEC 19757-2, as defined at
http://www.y12.doe.gov/sgml/sc34/document/0362_files/relaxng-is.pdf

In order to cater for the constraints on phoneme attributes, I've used
the sun multi-scheme validator which embeds a schematron processor.
XSD can't hack it.




<?xml version="1.0" encoding="UTF-8"?>
<grammar 
ns="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:tgt="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" 
xmlns="http://relaxng.org/ns/structure/1.0" 
xmlns:html ="http://www.w3.org/1999/xhtml"
xmlns:s = "http://www.ascc.net/xml/schematron"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">


 
  <a:documentation>
    <html:h2>  Demo's the use of Relax ng.</html:h2>
    <html:p>Revision 1.1 </html:p>
    <html:p>  gyear is the 4 digit year format </html:p>
  </a:documentation>

 <!-- root element -->
  <start>
    <ref name="Lexicon"/>
  </start>


<define name="Lexicon">
  <a:documentation>
    <html:p>Element  lexicon. Document root</html:p>
  </a:documentation>
  <element name="lexicon">
    <interleave>
    <attribute name="alphabet">
      <text/>
    </attribute>
    <attribute name="version">
      <value type="token">1.0</value>
    </attribute>
    <attribute name="xml:lang">
        <data type="language">
        </data>
    </attribute>
    <attribute name="xml:base">
        <data type="anyURI">
        </data>
    </attribute>

    </interleave>
    <zeroOrMore>
      <ref name="Meta"/>
    </zeroOrMore>
    <zeroOrMore>	
      <ref name="Metadata"/>
    </zeroOrMore>
    <zeroOrMore>
	<ref name="Lexeme"/>
    </zeroOrMore>
      <s:assert
	  test="count(tgt:meta[@http-equiv]) = 1">
	There must be one, and only one http-equiv attribute on a meta element
      </s:assert>
  </element>
</define>



<define name="Lexeme">
  <a:documentation>
    <html:p>Element lexeme. Single PLS entry </html:p>
  </a:documentation>
  <element name="lexeme">
    <oneOrMore>
      <ref name="Grapheme"/>
    </oneOrMore>
    <choice>
      <optional>
	<oneOrMore>
	  <ref name="Phoneme"/>
	</oneOrMore>
      </optional>
      <group>
	<ref name="Alias"/>

      </group>
    </choice>
    <zeroOrMore>
      <ref name="Example"/>
    </zeroOrMore>
<!-- lexeme context,  -->
      <s:assert 
	  test = "((count(tgt:phoneme) &gt; 1 and count(tgt:phoneme/@prefer) = 1)) or not(tgt:phoneme)">
	Must have at least one @prefer attribut when more than one phoneme element
      </s:assert>
  </element>
</define>

<define name="Meta">
  <a:documentation>
    <html:p>Element meta. Metadata container </html:p>
  </a:documentation>
  <element name="meta">

    <choice>
      <attribute name="name"><text/></attribute>
      <attribute name="http-equiv"><text/></attribute>
    </choice>
    <attribute name="content"><text/></attribute>
    <empty/>
  </element>
</define>

<define name="Metadata">
  <a:documentation>
    <html:p>Element metameta. Metadata entry </html:p>
  </a:documentation>
  <element name="metadata">
   <ref name="foreign-elements"/>
  </element>
</define>

<define name="Phoneme">
  <a:documentation>
    <html:p>Element  phoneme</html:p>
  </a:documentation>
  <element name="phoneme">
  
    <optional>
      <attribute name="alphabet">
	<choice>
	  <value type="token">ipa</value>
	  <data type="token">
	    <param name="pattern">x-[\p{L}]+</param>
	  </data>
	</choice>
      </attribute>
    </optional>
    <optional>
      <attribute name="prefer">
	<choice>
	  <value type="token">true</value>
	  <value type="token">false</value>
	</choice>
      </attribute>
    </optional>
    <text/>
  </element>
</define>

<define name="Grapheme">
  <a:documentation>
    <html:p>Element grapheme </html:p>
  </a:documentation>
  <element name="grapheme">
    <optional>
      <attribute name="orthography">
  <a:documentation>
    <html:p>Attribute orthography. Identifies the script code used for
    writing the orthography. The script code must be compliant with
    ISO 15924 [ISO15924].</html:p>
  </a:documentation>
	<text/>
      </attribute>
    </optional>
    <text/>
  </element>
</define>


<define name="Alias">
  <a:documentation>
    <html:p>Element alias  </html:p>
  </a:documentation>
  <element name="alias">
    <text/>
  </element>
</define>

<define name="Example">
  <a:documentation>
    <html:p>Element  example</html:p>
  </a:documentation>
  <element name="example">
    <text/>
  </element>
</define>


  <define name="foreign-elements">
    <a:documentation>
      <html:p id="foreign-elements">Element xxx, anything which isn't in the same namespace as the
      source document and its one other used ns.</html:p>
    </a:documentation>
    <element>
      <anyName>
	<except>
	  <nsName ns="http://www.ascc.net/xml/schematron"/>
	  <nsName ns="http://www.w3.org/2005/01/pronunciation-lexicon"/>
	  <nsName/>
	</except>
      </anyName>
      <ref name="anything"/>
    </element>
  </define>

  <define name="anything">
    <a:documentation>
      <html:p>Element YYY. Used by <html:a
      href="#foreign-elements">foreign-elements</html:a></html:p>
    </a:documentation>
    <zeroOrMore>
      <choice>
        <element>
          <anyName/>
          <ref name="anything"/>
        </element>
        <attribute>
          <anyName/>
        </attribute>
        <text/>
      </choice>
    </zeroOrMore>
  </define>

<!-- 
<define name="">
  <a:documentation>
    <html:p>Element  </html:p>
  </a:documentation>
  <element name="">

  </element>
</define>

 -->

</grammar>


regards DaveP

-- 
DISCLAIMER:

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged.  If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system.

RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants.  However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent
those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk

Received on Wednesday, 9 March 2005 07:58:48 UTC