This page last changed on Apr 15, 2007 by amitku.

RelaxNG schema

<?xml version="1.0" encoding="UTF-8"?>
<grammar 
  xmlns="http://relaxng.org/ns/structure/1.0"
  xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
  datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
  >
    <start>
        <element name="collection">
            <attribute name="id">
                <data type="ID"/>
            </attribute>
            <attribute name="stage">
                <data type="xsd:Integer"/>
            </attribute>
            <optional>
                
            <attribute name="date-modified">
                <data type="xsd:Date"/>
            </attribute>
            </optional>
            
            <ref name="head-desc"/>
            <ref name="body-desc"/>
        </element>
    </start>
    <define name="body-desc">
    <element name="body">
    <oneOrMore>
        <ref name="div-desc"/>
    </oneOrMore>
    </element>
    </define>
    
    
    <define name="div-desc">
        <element name="div">
            <attribute name="id"><data type="ID"/></attribute>
            <optional>
            <attribute name="expand">
                <a:documentation>Allowed values</a:documentation>
                <choice>
                    <value type="token">true</value>
                    <value type="token">false</value>
                </choice>
            </attribute>
            </optional>
            <attribute name="name">
                <a:documentation>Allowed types</a:documentation>
                <choice>
                    <value type="token">work</value>
                    <value type="token">volume</value>
                    <value type="token">section</value>
                    <value type="token">chapter</value>
                    <value type="token">paragraph</value>
                    <value type="token">letter</value>
                    <value type="token">lg</value>
                    <value type="token">l</value>
                    <value type="token">s</value>
                </choice>
            </attribute>
            <optional>
                <attribute name="equivalent">
                    <choice>
                    <value type="token">work</value>
                    <value type="token">volume</value>
                    <value type="token">section</value>
                    <value type="token">chapter</value>
                    <value type="token">paragraph</value>
                    <value type="token">letter</value>
                    <value type="token">lg</value>
                    <value type="token">l</value>
                    <value type="token">s</value>
                    </choice>
                </attribute>
            </optional>
            
            <ref name="label-desc"/>
            <optional>
                <ref name="meta-data-desc"/>
            </optional>
         
            <ref name="resources-desc"/>
            
            <zeroOrMore>
                <ref name="div-desc"/>
            </zeroOrMore>
            
        </element>
    </define>
    
    
    <define name="resources-desc">
        <element name="resources">
           <oneOrMore>
                <ref name="resource-desc"/>
            </oneOrMore>
        </element>
    </define>
    
    
    <define name="resource-desc">
        <element name="resource">
            <attribute name="ref">
                <data type="IDREF"/>
            </attribute>
            <attribute name="type">
                <choice>
                    <value type="token">fileset</value>
                    <value type="token">file</value>
                </choice>
            </attribute>
         <zeroOrMore>
             <ref name="xpath-desc"/>
         </zeroOrMore>   
        <zeroOrMore>
            <ref name="transform-desc"/>
        </zeroOrMore>    
        </element>
    </define>
    
    <define name="head-desc">
            <element name="head">
                <group>
               <ref name="label-desc"/>
                
              <ref name="meta-data-desc"/>
                
                <element name="files">
                <element name="filestore"><text/></element>    
                <interleave>
                    <a:documentation> A collection has atleast one fileset; the file element is optional</a:documentation>
                <oneOrMore>
                    <ref name="fileset-desc"/>
                </oneOrMore>
                 <zeroOrMore>
                        <ref name="file-desc"/>
                 </zeroOrMore>
                </interleave>
                </element>
                    <ref name="transform-desc"/>
                    <ref name="xmlDb-desc"/>
                    
                   
                </group>
            </element>
    </define>
    
    <define name="xmlDb-desc">
        <element name="xmlDb">
            <element name="url">
                <text/>
            </element>
            <element name="collection">
                <text/>
            </element>
        </element>
    </define>
    
    <define name="transform-desc">
        <element name="transform">
            <zeroOrMore>
                <ref name="pre-desc"/>
            </zeroOrMore>
        </element>
    </define>
    
    <define name="fileset-desc">
        <element name="fileset">
            <attribute name="id">
                <data type="ID"/>
            </attribute>
            <oneOrMore>
                <ref name="file-desc"/>
            </oneOrMore>
        </element>
    </define>
    <define name="file-desc">
        <element name="file">
            <attribute name="id">
                <data type="ID"/>
            </attribute>
            <text/>
        </element>
        
    </define>
    
    <define name="xpath-desc">
        <element name="xpath">
            <text/>
            <attribute name="type" >
                <a:documentation>Allowed types</a:documentation>
                <choice>
                    <value type="token">absolute</value>
                    <value type="token">relative</value>
                 </choice>
            </attribute>
        </element>
    </define>
    
    <define name="pre-desc">
        <element name="pre">
            <attribute name="condition"/>
            <optional>
            <ref name="if-then-else-desc"/>
            </optional>
           
           <optional>
               <ref name="xpath-desc"/>
           </optional>
            
            <optional>
               <ref name="append-desc"/>
           </optional>
        </element>
    </define>
    
    <define name="if-then-else-desc">
        <element name="if">
           <a:documentation>nested if can happpen</a:documentation>
            <group>
            <element name="equals">
                <attribute name="args"/>
            </element>
            <ref name="then-desc"/>
            <optional>
                <ref name="else-desc"/>
            </optional>
            </group>
        </element>
        
        
    </define>
    <define name="then-desc">
        <element name="then">
            <choice>
            <optional>
              <ref name="append-desc"/>
            </optional>
            <zeroOrMore>
                <ref name="if-then-else-desc"/>
            </zeroOrMore>
             </choice>
        </element>
        <!-- NEED TO WORK HERE -->
        <!-- IF THEN ELSE CONSTRUCT CAN NOT OCCUR HERE -->
        
        
    </define>
    
    <define name="else-desc">
        <element name="else">
          <choice>
            <choice>            
            <optional>
                <ref name="append-desc"/>
            </optional>
            </choice>
            
            <choice>
            <zeroOrMore>
            <ref name="if-then-else-desc"/>
            </zeroOrMore>
            <ref name="continue-desc"/>
            </choice>
            </choice>
        </element>
        <!-- NEED TO WORK HERE -->
        
        <!-- IF THEN ELSE CONSTRUCT CAN OCCUR HERE -->
    </define>
    
    <define name="append-desc">
        <choice>
        <element name="append">
            <attribute name="type">
                    <value type="token">element</value>
             </attribute>
            <attribute name="name">
               <text/>
            </attribute>
            <element name="value"><text/></element>
            <zeroOrMore>
            <ref name="append-desc"/>
            </zeroOrMore>
        </element>
            
            <element name="append">
                <attribute name="type">
                        <value type="token">attribute</value>
                </attribute>
                <attribute name="name">
                    <text/>
                </attribute>
                <element name="value"><text/></element>
               </element>
        
            </choice>
        
    </define>
    
    <define name="continue-desc">
        <element name="continue"><empty/></element>
    </define>
    
    <define name="label-desc">
    <element name="label">
     <!--   <choice>
            <text/>
            <group>
                <ref name="xpath-desc"/>
            </group>
        </choice>
        -->
        <data type="xsd:any"/>
    </element>
    </define>
    
    <define name="meta-data-desc">
        <choice>
        <element name="meta-data">
            <a:documentation> Collection specific metadata</a:documentation>
            <text/>
        </element>
            <element name="meta-data">
                <a:documentation> Collection specific metadata</a:documentation>
            <ref name="xpath-desc"/>
            </element>
            
        </choice>
    </define>
    
    
</grammar>


Document generated by Confluence on Apr 19, 2009 15:04