RelaxNG/publiset.rng
changeset 0 41a5385c69a2
child 2 417bb62f2a77
equal deleted inserted replaced
-1:000000000000 0:41a5385c69a2
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
       
     3   <!-- $Id$ -->
       
     4   <start>
       
     5     <ref name="publiset"/>
       
     6   </start>
       
     7   <define name="publiset">
       
     8     <element name="publiset">
       
     9       <ref name="publiset.attributes"/>
       
    10       <ref name="publiset.content"/>
       
    11     </element>
       
    12   </define>
       
    13   <!-- ~~~~~~ attributes -->
       
    14   <define name="publiset.attributes">
       
    15     <ref name="version.attribute"/>
       
    16   </define>
       
    17   <define name="version.attribute">
       
    18     <attribute name="version">
       
    19       <value>1.0</value>
       
    20     </attribute>
       
    21   </define>
       
    22   <!-- ~~~~~~ content -->
       
    23   <define name="publiset.content">
       
    24     <oneOrMore>
       
    25       <choice>
       
    26         <ref name="composition"/>
       
    27         <ref name="selection"/>
       
    28       </choice>
       
    29     </oneOrMore>
       
    30   </define>
       
    31   <!--
       
    32     =============================================================================
       
    33                                      Top level
       
    34     =============================================================================
       
    35   -->
       
    36   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
    37   <define name="composition">
       
    38     <element name="composition">
       
    39       <ref name="composition.attributes"/>
       
    40       <ref name="composition.content"/>
       
    41     </element>
       
    42   </define>
       
    43   <!-- ~~~~~~ attributes -->
       
    44   <define name="composition.attributes">
       
    45     <interleave>
       
    46       <ref name="composition.id.attribute"/>
       
    47       <optional>
       
    48         <ref name="base.attribute"/>
       
    49       </optional>
       
    50       <ref name="remap.attributes"/>
       
    51     </interleave>
       
    52   </define>
       
    53   <define name="composition.id.attribute">
       
    54     <attribute name="xml:id">
       
    55       <data type="ID"/>
       
    56     </attribute>
       
    57   </define>
       
    58   <define name="base.attribute">
       
    59     <attribute name="xml:base">
       
    60       <data type="anyURI"/>
       
    61     </attribute>
       
    62   </define>
       
    63   <!-- ~~~~~~ content -->
       
    64   <define name="composition.content">
       
    65     <optional>
       
    66       <ref name="composition.metadata"/>
       
    67     </optional>
       
    68     <oneOrMore>
       
    69       <choice>
       
    70         <ref name="composition.file"/>
       
    71         <ref name="composition.division"/>
       
    72       </choice>
       
    73     </oneOrMore>
       
    74   </define>
       
    75   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
    76   <define name="selection">
       
    77     <element name="selection">
       
    78       <ref name="selection.attributes"/>
       
    79       <ref name="selection.content"/>
       
    80     </element>
       
    81   </define>
       
    82   <!-- ~~~~~~ attributes -->
       
    83   <define name="selection.attributes">
       
    84     <optional>
       
    85       <ref name="base.attribute"/>
       
    86     </optional>
       
    87   </define>
       
    88   <define name="selection.id.attribute">
       
    89     <attribute name="xml:id">
       
    90       <data type="ID"/>
       
    91     </attribute>
       
    92   </define>
       
    93   <!-- ~~~~~~ content -->
       
    94   <define name="selection.content">
       
    95     <optional>
       
    96       <ref name="selection.metadata"/>
       
    97     </optional>
       
    98     <oneOrMore>
       
    99       <choice>
       
   100         <ref name="selection.file"/>
       
   101         <ref name="selection.division"/>
       
   102       </choice>
       
   103     </oneOrMore>
       
   104   </define>
       
   105   <!--
       
   106     =============================================================================
       
   107                                     Metadata level
       
   108     =============================================================================
       
   109   -->
       
   110   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   111   <define name="composition.metadata">
       
   112     <element name="metadata">
       
   113       <ref name="metadata.attributes"/>
       
   114       <ref name="metadata.content"/>
       
   115     </element>
       
   116   </define>
       
   117   <define name="selection.metadata">
       
   118     <element name="metadata">
       
   119       <ref name="metadata.content"/>
       
   120     </element>
       
   121   </define>
       
   122   <!-- ~~~~~~ attributes -->
       
   123   <define name="metadata.attributes">
       
   124     <ref name="remap.attributes"/>
       
   125   </define>
       
   126   <!-- ~~~~~~ content -->
       
   127   <define name="metadata.content">
       
   128     <optional>
       
   129       <ref name="title"/>
       
   130     </optional>
       
   131     <optional>
       
   132       <ref name="subtitle"/>
       
   133     </optional>
       
   134     <optional>
       
   135       <ref name="source"/>
       
   136     </optional>
       
   137   </define>
       
   138   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   139   <define name="title">
       
   140     <element name="title">
       
   141       <ref name="title.content"/>
       
   142     </element>
       
   143   </define>
       
   144   <define name="title.content">
       
   145     <ref name="inlines"/>
       
   146   </define>
       
   147   <define name="subtitle">
       
   148     <element name="subtitle">
       
   149       <ref name="title.content"/>
       
   150     </element>
       
   151   </define>
       
   152   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   153   <define name="source">
       
   154     <element name="source">
       
   155       <ref name="source.attributes"/>
       
   156       <choice>
       
   157         <group>
       
   158           <attribute name="type">
       
   159             <value>book</value>
       
   160           </attribute>
       
   161           <ref name="source.content.book"/>
       
   162         </group>
       
   163         <attribute name="type">
       
   164           <value>file</value>
       
   165         </attribute>
       
   166       </choice>
       
   167     </element>
       
   168   </define>
       
   169   <!-- ~~~~~~ Attributes -->
       
   170   <define name="source.attributes">
       
   171     <interleave>
       
   172       <optional>
       
   173         <ref name="source.id.attribute"/>
       
   174       </optional>
       
   175       <ref name="remap.attributes"/>
       
   176     </interleave>
       
   177   </define>
       
   178   <define name="source.id.attribute">
       
   179     <attribute name="id">
       
   180       <data type="NMTOKEN"/>
       
   181     </attribute>
       
   182   </define>
       
   183   <!-- ~~~~~~ Content -->
       
   184   <define name="source.content.book">
       
   185     <optional>
       
   186       <ref name="title"/>
       
   187     </optional>
       
   188     <optional>
       
   189       <ref name="pagenumber"/>
       
   190     </optional>
       
   191   </define>
       
   192   <define name="pagenumber">
       
   193     <element name="pagenumber">
       
   194       <ref name="pagenumber.attributes"/>
       
   195     </element>
       
   196   </define>
       
   197   <define name="pagenumber.attributes">
       
   198     <ref name="pagenumber.value.attribute"/>
       
   199   </define>
       
   200   <define name="pagenumber.value.attribute">
       
   201     <attribute name="value">
       
   202       <ref name="pagenumber.value.enumeration"/>
       
   203     </attribute>
       
   204   </define>
       
   205   <define name="pagenumber.value.enumeration">
       
   206     <data type="positiveInteger"/>
       
   207   </define>
       
   208   <!--
       
   209     =============================================================================
       
   210                                    Division level
       
   211     =============================================================================
       
   212   -->
       
   213   <define name="composition.division">
       
   214     <element name="division">
       
   215       <ref name="composition.division.attributes"/>
       
   216       <ref name="composition.division.content"/>
       
   217     </element>
       
   218   </define>
       
   219   <define name="selection.division">
       
   220     <element name="division">
       
   221       <ref name="selection.division.attributes"/>
       
   222       <ref name="selection.division.content"/>
       
   223     </element>
       
   224   </define>
       
   225   <!-- ~~~~~~ attributes -->
       
   226   <define name="composition.division.attributes">
       
   227     <interleave>
       
   228       <optional>
       
   229         <ref name="base.attribute"/>
       
   230       </optional>
       
   231       <ref name="remap.attributes"/>
       
   232     </interleave>
       
   233   </define>
       
   234   <define name="selection.division.attributes">
       
   235     <optional>
       
   236       <ref name="base.attribute"/>
       
   237     </optional>
       
   238   </define>
       
   239   <!-- ~~~~~~ content -->
       
   240   <define name="composition.division.content">
       
   241     <optional>
       
   242       <ref name="composition.metadata"/>
       
   243     </optional>
       
   244     <oneOrMore>
       
   245       <choice>
       
   246         <ref name="composition.file"/>
       
   247         <ref name="composition.division"/>
       
   248       </choice>
       
   249     </oneOrMore>
       
   250   </define>
       
   251   <define name="selection.division.content">
       
   252     <optional>
       
   253       <ref name="selection.metadata"/>
       
   254     </optional>
       
   255     <oneOrMore>
       
   256       <choice>
       
   257         <ref name="selection.file"/>
       
   258         <ref name="selection.division"/>
       
   259       </choice>
       
   260     </oneOrMore>
       
   261   </define>
       
   262   <!--
       
   263     =============================================================================
       
   264                                      File level
       
   265     =============================================================================
       
   266   -->
       
   267   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   268   <define name="composition.file">
       
   269     <element name="file">
       
   270       <ref name="composition.file.attributes"/>
       
   271     </element>
       
   272   </define>
       
   273   <define name="selection.file">
       
   274     <element name="file">
       
   275       <ref name="selection.file.attributes"/>
       
   276     </element>
       
   277   </define>
       
   278   <!-- ~~~~~~ attributes -->
       
   279   <define name="composition.file.attributes">
       
   280     <interleave>
       
   281       <ref name="name.attribute"/>
       
   282       <optional>
       
   283         <ref name="xpath.attribute"/>
       
   284       </optional>
       
   285       <ref name="remap.attributes"/>
       
   286     </interleave>
       
   287   </define>
       
   288   <define name="selection.file.attributes">
       
   289     <interleave>
       
   290       <ref name="name.attribute"/>
       
   291       <optional>
       
   292         <ref name="xpath.attribute"/>
       
   293       </optional>
       
   294     </interleave>
       
   295   </define>
       
   296   <define name="name.attribute">
       
   297     <attribute name="name"/>
       
   298   </define>
       
   299   <define name="xpath.attribute">
       
   300     <attribute name="xpath"/>
       
   301   </define>
       
   302   <!--
       
   303     =============================================================================
       
   304                                     Inline level
       
   305     =============================================================================
       
   306   -->
       
   307   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   308   <define name="inlines">
       
   309     <mixed>
       
   310       <interleave>
       
   311         <zeroOrMore>
       
   312           <ref name="sup"/>
       
   313         </zeroOrMore>
       
   314         <zeroOrMore>
       
   315           <ref name="sub"/>
       
   316         </zeroOrMore>
       
   317       </interleave>
       
   318     </mixed>
       
   319   </define>
       
   320   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   321   <define name="sup">
       
   322     <element name="sup">
       
   323       <ref name="inlines"/>
       
   324     </element>
       
   325   </define>
       
   326   <define name="sub">
       
   327     <element name="sub">
       
   328       <ref name="inlines"/>
       
   329     </element>
       
   330   </define>
       
   331   <!--
       
   332     =============================================================================
       
   333                                   Remap attributes
       
   334     =============================================================================
       
   335   -->
       
   336   <define name="remap.attributes">
       
   337     <interleave>
       
   338       <optional>
       
   339         <ref name="as.attribute"/>
       
   340       </optional>
       
   341       <optional>
       
   342         <ref name="attributes.attribute"/>
       
   343       </optional>
       
   344     </interleave>
       
   345   </define>
       
   346   <define name="as.attribute">
       
   347     <attribute name="as">
       
   348       <data type="QName"/>
       
   349     </attribute>
       
   350   </define>
       
   351   <define name="attributes.attribute">
       
   352     <attribute name="attributes">
       
   353       <list>
       
   354         <oneOrMore>
       
   355           <data type="token">
       
   356             <param name="pattern">\c+=\S+</param>
       
   357           </data>
       
   358         </oneOrMore>
       
   359       </list>
       
   360     </attribute>
       
   361   </define>
       
   362 </grammar>