RelaxNG/publiset.rng
changeset 73 0a3a8006996b
parent 72 c85252fac80c
child 74 ebe0ab8699fc
equal deleted inserted replaced
72:c85252fac80c 73:0a3a8006996b
     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   <define name="publiset.attributes">
       
    14     <ref name="version.attribute"/>
       
    15   </define>
       
    16   <define name="version.attribute">
       
    17     <attribute name="version">
       
    18       <value>1.0</value>
       
    19     </attribute>
       
    20   </define>
       
    21   <define name="publiset.content">
       
    22     <oneOrMore>
       
    23       <choice>
       
    24         <ref name="composition"/>
       
    25         <ref name="selection"/>
       
    26       </choice>
       
    27     </oneOrMore>
       
    28   </define>
       
    29   <!--
       
    30     =============================================================================
       
    31                                      TOP LEVEL
       
    32     =============================================================================
       
    33   -->
       
    34   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
    35   <define name="composition">
       
    36     <element name="composition">
       
    37       <ref name="composition.attributes"/>
       
    38       <ref name="composition.content"/>
       
    39     </element>
       
    40   </define>
       
    41   <define name="composition.attributes">
       
    42     <interleave>
       
    43       <ref name="composition.id.attribute"/>
       
    44       <optional>
       
    45         <ref name="path.attribute"/>
       
    46       </optional>
       
    47       <optional>
       
    48         <ref name="xpath.attribute"/>
       
    49       </optional>
       
    50       <optional>
       
    51         <ref name="xslt.attribute"/>
       
    52       </optional>
       
    53       <ref name="remap.attributes"/>
       
    54       <optional>
       
    55         <ref name="lang.attribute"/>
       
    56       </optional>
       
    57     </interleave>
       
    58   </define>
       
    59   <define name="composition.id.attribute">
       
    60     <attribute name="xml:id">
       
    61       <data type="ID"/>
       
    62     </attribute>
       
    63   </define>
       
    64   <define name="path.attribute">
       
    65     <attribute name="path">
       
    66       <data type="anyURI"/>
       
    67     </attribute>
       
    68   </define>
       
    69   <define name="xslt.attribute">
       
    70     <attribute name="xslt">
       
    71       <data type="anyURI"/>
       
    72     </attribute>
       
    73   </define>
       
    74   <define name="xpath.attribute">
       
    75     <attribute name="xpath"/>
       
    76   </define>
       
    77   <define name="lang.attribute">
       
    78     <attribute name="xml:lang">
       
    79       <data type="language"/>
       
    80     </attribute>
       
    81   </define>
       
    82   <define name="composition.content">
       
    83     <optional>
       
    84       <ref name="composition.head"/>
       
    85     </optional>
       
    86     <oneOrMore>
       
    87       <choice>
       
    88         <ref name="composition.division"/>
       
    89         <ref name="composition.file"/>
       
    90       </choice>
       
    91     </oneOrMore>
       
    92   </define>
       
    93   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
    94   <define name="selection">
       
    95     <element name="selection">
       
    96       <ref name="selection.attributes"/>
       
    97       <ref name="selection.content"/>
       
    98     </element>
       
    99   </define>
       
   100   <define name="selection.attributes">
       
   101     <interleave>
       
   102       <ref name="selection.id.attribute"/>
       
   103       <optional>
       
   104         <ref name="path.attribute"/>
       
   105       </optional>
       
   106       <optional>
       
   107         <ref name="lang.attribute"/>
       
   108       </optional>
       
   109     </interleave>
       
   110   </define>
       
   111   <define name="selection.id.attribute">
       
   112     <attribute name="xml:id">
       
   113       <data type="ID"/>
       
   114     </attribute>
       
   115   </define>
       
   116   <define name="selection.content">
       
   117     <optional>
       
   118       <ref name="selection.head"/>
       
   119     </optional>
       
   120     <oneOrMore>
       
   121       <choice>
       
   122         <ref name="selection.division"/>
       
   123         <ref name="selection.file"/>
       
   124         <ref name="link"/>
       
   125       </choice>
       
   126     </oneOrMore>
       
   127   </define>
       
   128   <!--
       
   129     =============================================================================
       
   130                                      HEAD LEVEL
       
   131     =============================================================================
       
   132   -->
       
   133   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   134   <define name="composition.head">
       
   135     <element name="head">
       
   136       <ref name="head.attributes"/>
       
   137       <ref name="top.head.content"/>
       
   138     </element>
       
   139   </define>
       
   140   <define name="selection.head">
       
   141     <element name="head">
       
   142       <ref name="top.head.content"/>
       
   143     </element>
       
   144   </define>
       
   145   <define name="division.head">
       
   146     <element name="head">
       
   147       <ref name="division.head.content"/>
       
   148     </element>
       
   149   </define>
       
   150   <define name="head.attributes">
       
   151     <ref name="remap.attributes"/>
       
   152   </define>
       
   153   <define name="top.head.content">
       
   154     <interleave>
       
   155       <optional>
       
   156         <ref name="title"/>
       
   157         <optional>
       
   158           <ref name="subtitle"/>
       
   159         </optional>
       
   160       </optional>
       
   161       <zeroOrMore>
       
   162         <ref name="identifier"/>
       
   163       </zeroOrMore>
       
   164       <optional>
       
   165         <ref name="copyright"/>
       
   166       </optional>
       
   167       <optional>
       
   168         <ref name="contributors"/>
       
   169       </optional>
       
   170       <optional>
       
   171         <ref name="abstract"/>
       
   172       </optional>
       
   173       <optional>
       
   174         <ref name="cover"/>
       
   175       </optional>
       
   176     </interleave>
       
   177   </define>
       
   178   <define name="division.head.content">
       
   179     <optional>
       
   180       <ref name="title"/>
       
   181       <optional>
       
   182         <ref name="subtitle"/>
       
   183       </optional>
       
   184     </optional>
       
   185   </define>
       
   186   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   187   <define name="title">
       
   188     <element name="title">
       
   189       <ref name="title.content"/>
       
   190     </element>
       
   191   </define>
       
   192   <define name="subtitle">
       
   193     <element name="subtitle">
       
   194       <ref name="title.content"/>
       
   195     </element>
       
   196   </define>
       
   197   <define name="title.content">
       
   198     <ref name="inlines"/>
       
   199   </define>
       
   200   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   201   <define name="identifier.uri">
       
   202     <element name="identifier">
       
   203       <attribute name="type">
       
   204         <value>uri</value>
       
   205       </attribute>
       
   206       <data type="anyURI"/>
       
   207     </element>
       
   208   </define>
       
   209   <define name="identifier.ean">
       
   210     <element name="identifier">
       
   211       <attribute name="type">
       
   212         <value>ean</value>
       
   213       </attribute>
       
   214       <data type="token">
       
   215         <param name="pattern">\d{13}</param>
       
   216       </data>
       
   217     </element>
       
   218   </define>
       
   219   <define name="identifier">
       
   220     <choice>
       
   221       <ref name="identifier.uri"/>
       
   222       <ref name="identifier.ean"/>
       
   223     </choice>
       
   224   </define>
       
   225   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   226   <define name="copyright">
       
   227     <element name="copyright">
       
   228       <ref name="copyright.content"/>
       
   229     </element>
       
   230   </define>
       
   231   <define name="copyright.content">
       
   232     <ref name="inlines"/>
       
   233   </define>
       
   234   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   235   <!-- ~~~~~~ contributors -->
       
   236   <define name="contributors">
       
   237     <element name="contributors">
       
   238       <ref name="contributors.content"/>
       
   239     </element>
       
   240   </define>
       
   241   <define name="contributors.content">
       
   242     <oneOrMore>
       
   243       <ref name="contributor"/>
       
   244     </oneOrMore>
       
   245   </define>
       
   246   <!-- ~~~~~~ contributor -->
       
   247   <define name="contributor">
       
   248     <element name="contributor">
       
   249       <ref name="contributor.content"/>
       
   250     </element>
       
   251   </define>
       
   252   <define name="contributor.content">
       
   253     <choice>
       
   254       <group>
       
   255         <optional>
       
   256           <ref name="firstname"/>
       
   257           <optional>
       
   258             <ref name="secondname"/>
       
   259           </optional>
       
   260         </optional>
       
   261         <ref name="lastname"/>
       
   262       </group>
       
   263       <ref name="label"/>
       
   264     </choice>
       
   265     <optional>
       
   266       <ref name="address"/>
       
   267     </optional>
       
   268     <optional>
       
   269       <ref name="link"/>
       
   270     </optional>
       
   271     <zeroOrMore>
       
   272       <ref name="role"/>
       
   273     </zeroOrMore>
       
   274   </define>
       
   275   <!-- ~~~~~~ firstname, secondname, lastname, label -->
       
   276   <define name="firstname">
       
   277     <element name="firstname">
       
   278       <ref name="firstname.content"/>
       
   279     </element>
       
   280   </define>
       
   281   <define name="secondname">
       
   282     <element name="secondname">
       
   283       <ref name="secondname.content"/>
       
   284     </element>
       
   285   </define>
       
   286   <define name="lastname">
       
   287     <element name="lastname">
       
   288       <ref name="lastname.content"/>
       
   289     </element>
       
   290   </define>
       
   291   <define name="label">
       
   292     <element name="label">
       
   293       <ref name="label.content"/>
       
   294     </element>
       
   295   </define>
       
   296   <define name="firstname.content">
       
   297     <ref name="inlines"/>
       
   298   </define>
       
   299   <define name="secondname.content">
       
   300     <ref name="inlines"/>
       
   301   </define>
       
   302   <define name="lastname.content">
       
   303     <ref name="inlines"/>
       
   304   </define>
       
   305   <define name="label.content">
       
   306     <ref name="inlines"/>
       
   307   </define>
       
   308   <!-- ~~~~~~ address -->
       
   309   <define name="address">
       
   310     <element name="address">
       
   311       <ref name="address.content"/>
       
   312     </element>
       
   313   </define>
       
   314   <define name="address.content">
       
   315     <ref name="inlines"/>
       
   316   </define>
       
   317   <!-- ~~~~~~ role -->
       
   318   <define name="role">
       
   319     <element name="role">
       
   320       <ref name="role.content"/>
       
   321     </element>
       
   322   </define>
       
   323   <define name="role.content">
       
   324     <choice>
       
   325       <value>author</value>
       
   326       <value>illustrator</value>
       
   327       <value>publisher</value>
       
   328     </choice>
       
   329   </define>
       
   330   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   331   <define name="abstract">
       
   332     <element name="abstract">
       
   333       <ref name="abstract.content"/>
       
   334     </element>
       
   335   </define>
       
   336   <define name="abstract.content">
       
   337     <oneOrMore>
       
   338       <ref name="p"/>
       
   339     </oneOrMore>
       
   340   </define>
       
   341   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   342   <define name="cover">
       
   343     <element name="cover">
       
   344       <ref name="cover.content"/>
       
   345     </element>
       
   346   </define>
       
   347   <define name="cover.content">
       
   348     <ref name="cover.image"/>
       
   349   </define>
       
   350   <define name="cover.image">
       
   351     <element name="image">
       
   352       <ref name="cover.image.attributes"/>
       
   353     </element>
       
   354   </define>
       
   355   <define name="cover.image.attributes">
       
   356     <ref name="cover.image.id.attribute"/>
       
   357   </define>
       
   358   <define name="cover.image.id.attribute">
       
   359     <attribute name="id">
       
   360       <data type="NMTOKEN"/>
       
   361     </attribute>
       
   362   </define>
       
   363   <!--
       
   364     =============================================================================
       
   365                                    DIVISION LEVEL
       
   366     =============================================================================
       
   367   -->
       
   368   <define name="composition.division">
       
   369     <element name="division">
       
   370       <ref name="composition.division.attributes"/>
       
   371       <ref name="composition.division.content"/>
       
   372     </element>
       
   373   </define>
       
   374   <define name="selection.division">
       
   375     <element name="division">
       
   376       <ref name="selection.division.attributes"/>
       
   377       <ref name="selection.division.content"/>
       
   378     </element>
       
   379   </define>
       
   380   <define name="composition.division.attributes">
       
   381     <interleave>
       
   382       <optional>
       
   383         <ref name="path.attribute"/>
       
   384       </optional>
       
   385       <optional>
       
   386         <ref name="xpath.attribute"/>
       
   387       </optional>
       
   388       <optional>
       
   389         <ref name="xslt.attribute"/>
       
   390       </optional>
       
   391       <ref name="remap.attributes"/>
       
   392     </interleave>
       
   393   </define>
       
   394   <define name="selection.division.attributes">
       
   395     <optional>
       
   396       <ref name="path.attribute"/>
       
   397     </optional>
       
   398   </define>
       
   399   <define name="composition.division.content">
       
   400     <optional>
       
   401       <ref name="composition.head"/>
       
   402     </optional>
       
   403     <oneOrMore>
       
   404       <choice>
       
   405         <ref name="composition.division"/>
       
   406         <ref name="composition.file"/>
       
   407       </choice>
       
   408     </oneOrMore>
       
   409   </define>
       
   410   <define name="selection.division.content">
       
   411     <optional>
       
   412       <ref name="selection.head"/>
       
   413     </optional>
       
   414     <oneOrMore>
       
   415       <choice>
       
   416         <ref name="selection.division"/>
       
   417         <ref name="selection.file"/>
       
   418         <ref name="link"/>
       
   419       </choice>
       
   420     </oneOrMore>
       
   421   </define>
       
   422   <!--
       
   423     =============================================================================
       
   424                                      FILE LEVEL
       
   425     =============================================================================
       
   426   -->
       
   427   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   428   <define name="composition.file">
       
   429     <element name="file">
       
   430       <ref name="composition.file.attributes"/>
       
   431     </element>
       
   432   </define>
       
   433   <define name="selection.file">
       
   434     <element name="file">
       
   435       <ref name="selection.file.attributes"/>
       
   436       <ref name="file.content"/>
       
   437     </element>
       
   438   </define>
       
   439   <define name="composition.file.attributes">
       
   440     <interleave>
       
   441       <ref name="name.attribute"/>
       
   442       <optional>
       
   443         <ref name="xpath.attribute"/>
       
   444       </optional>
       
   445       <optional>
       
   446         <ref name="xslt.attribute"/>
       
   447       </optional>
       
   448     </interleave>
       
   449   </define>
       
   450   <define name="selection.file.attributes">
       
   451     <interleave>
       
   452       <ref name="name.attribute"/>
       
   453       <optional>
       
   454         <ref name="uri.attribute"/>
       
   455       </optional>
       
   456     </interleave>
       
   457   </define>
       
   458   <define name="name.attribute">
       
   459     <attribute name="name">
       
   460       <data type="anyURI"/>
       
   461     </attribute>
       
   462   </define>
       
   463   <define name="file.content">
       
   464     <ref name="inlines"/>
       
   465   </define>
       
   466   <!--
       
   467     =============================================================================
       
   468                                     BLOCK LEVEL
       
   469     =============================================================================
       
   470   -->
       
   471   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   472   <define name="p">
       
   473     <element name="p">
       
   474       <ref name="p.content"/>
       
   475     </element>
       
   476   </define>
       
   477   <define name="p.content">
       
   478     <ref name="inlines"/>
       
   479   </define>
       
   480   <!--
       
   481     =============================================================================
       
   482                                     INLINE LEVEL
       
   483     =============================================================================
       
   484   -->
       
   485   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   486   <define name="inlines">
       
   487     <mixed>
       
   488       <interleave>
       
   489         <zeroOrMore>
       
   490           <ref name="sup"/>
       
   491         </zeroOrMore>
       
   492         <zeroOrMore>
       
   493           <ref name="sub"/>
       
   494         </zeroOrMore>
       
   495       </interleave>
       
   496     </mixed>
       
   497   </define>
       
   498   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   499   <define name="sup">
       
   500     <element name="sup">
       
   501       <ref name="inlines"/>
       
   502     </element>
       
   503   </define>
       
   504   <define name="sub">
       
   505     <element name="sub">
       
   506       <ref name="inlines"/>
       
   507     </element>
       
   508   </define>
       
   509   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       
   510   <define name="link">
       
   511     <element name="link">
       
   512       <ref name="link.attributes"/>
       
   513       <ref name="link.content"/>
       
   514     </element>
       
   515   </define>
       
   516   <define name="link.attributes">
       
   517     <ref name="uri.attribute"/>
       
   518   </define>
       
   519   <define name="uri.attribute">
       
   520     <attribute name="uri">
       
   521       <data type="anyURI"/>
       
   522     </attribute>
       
   523   </define>
       
   524   <define name="link.content">
       
   525     <ref name="inlines"/>
       
   526   </define>
       
   527   <!--
       
   528     =============================================================================
       
   529                                   REMAP ATTRIBUTES
       
   530     =============================================================================
       
   531   -->
       
   532   <define name="remap.attributes">
       
   533     <interleave>
       
   534       <optional>
       
   535         <ref name="as.attribute"/>
       
   536       </optional>
       
   537       <optional>
       
   538         <ref name="attributes.attribute"/>
       
   539       </optional>
       
   540     </interleave>
       
   541   </define>
       
   542   <define name="as.attribute">
       
   543     <attribute name="as">
       
   544       <data type="QName"/>
       
   545     </attribute>
       
   546   </define>
       
   547   <define name="attributes.attribute">
       
   548     <attribute name="attributes">
       
   549       <list>
       
   550         <oneOrMore>
       
   551           <data type="token">
       
   552             <param name="pattern">\c+=\S+</param>
       
   553           </data>
       
   554         </oneOrMore>
       
   555       </list>
       
   556     </attribute>
       
   557   </define>
       
   558 </grammar>