RelaxNG/publiset.rnc
changeset 0 41a5385c69a2
child 2 417bb62f2a77
equal deleted inserted replaced
-1:000000000000 0:41a5385c69a2
       
     1 # $Id$
       
     2 
       
     3 start = publiset
       
     4 
       
     5 
       
     6 publiset = element publiset {
       
     7    publiset.attributes,
       
     8    publiset.content
       
     9 }
       
    10 
       
    11 # ~~~~~~ attributes
       
    12 publiset.attributes =
       
    13    version.attribute
       
    14 
       
    15 version.attribute = attribute version { "1.0" }
       
    16 
       
    17 # ~~~~~~ content
       
    18 publiset.content =
       
    19    (composition | selection)+
       
    20 
       
    21 
       
    22 # =============================================================================
       
    23 #                                  Top level
       
    24 # =============================================================================
       
    25 
       
    26 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    27 
       
    28 composition = element composition {
       
    29    composition.attributes,
       
    30    composition.content
       
    31 }
       
    32 
       
    33 # ~~~~~~ attributes
       
    34 composition.attributes =
       
    35    composition.id.attribute
       
    36  & base.attribute?
       
    37  & remap.attributes
       
    38 
       
    39 composition.id.attribute = attribute xml:id { xsd:ID }
       
    40 base.attribute = attribute xml:base { xsd:anyURI }
       
    41 
       
    42 # ~~~~~~ content
       
    43 composition.content =
       
    44    composition.metadata?,
       
    45    (composition.file | composition.division)+
       
    46 
       
    47 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    48 
       
    49 selection = element selection {
       
    50    selection.attributes,
       
    51    selection.content
       
    52 }
       
    53 
       
    54 # ~~~~~~ attributes
       
    55 selection.attributes =
       
    56    base.attribute?
       
    57 
       
    58 selection.id.attribute = attribute xml:id { xsd:ID }
       
    59 
       
    60 # ~~~~~~ content
       
    61 selection.content =
       
    62    selection.metadata?,
       
    63    (selection.file | selection.division)+
       
    64 
       
    65 
       
    66 # =============================================================================
       
    67 #                                 Metadata level
       
    68 # =============================================================================
       
    69 
       
    70 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    71 
       
    72 composition.metadata = element metadata {
       
    73    metadata.attributes,
       
    74    metadata.content
       
    75 }
       
    76 
       
    77 selection.metadata = element metadata { metadata.content }
       
    78 
       
    79 # ~~~~~~ attributes
       
    80 metadata.attributes =
       
    81    remap.attributes
       
    82 
       
    83 # ~~~~~~ content
       
    84 metadata.content =
       
    85    title?,
       
    86    subtitle?,
       
    87    source?
       
    88 
       
    89 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    90 
       
    91 title = element title { title.content }
       
    92 title.content = inlines
       
    93 
       
    94 subtitle = element subtitle { title.content }
       
    95 
       
    96 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    97 
       
    98 source = element source {
       
    99    source.attributes,
       
   100    (  (attribute type { "book" }, source.content.book)
       
   101     | (attribute type { "file" }))
       
   102 }
       
   103 
       
   104 # ~~~~~~ Attributes
       
   105 source.attributes =
       
   106    source.id.attribute?
       
   107  & remap.attributes
       
   108 
       
   109 source.id.attribute = attribute id { xsd:NMTOKEN }
       
   110 
       
   111 # ~~~~~~ Content
       
   112 source.content.book =
       
   113    title?,
       
   114    pagenumber?
       
   115 
       
   116 pagenumber = element pagenumber { pagenumber.attributes }
       
   117 pagenumber.attributes =
       
   118    pagenumber.value.attribute
       
   119 pagenumber.value.attribute = attribute value { pagenumber.value.enumeration }
       
   120 pagenumber.value.enumeration = xsd:positiveInteger
       
   121 
       
   122 
       
   123 # =============================================================================
       
   124 #                                Division level
       
   125 # =============================================================================
       
   126 
       
   127 composition.division = element division {
       
   128    composition.division.attributes,
       
   129    composition.division.content
       
   130 }
       
   131 
       
   132 selection.division = element division {
       
   133    selection.division.attributes,
       
   134    selection.division.content
       
   135 }
       
   136 
       
   137 # ~~~~~~ attributes
       
   138 composition.division.attributes =
       
   139    base.attribute?
       
   140  & remap.attributes
       
   141 
       
   142 selection.division.attributes =
       
   143    base.attribute?
       
   144 
       
   145 # ~~~~~~ content
       
   146 composition.division.content =
       
   147    composition.metadata?,
       
   148    (composition.file | composition.division)+
       
   149 
       
   150 selection.division.content =
       
   151    selection.metadata?,
       
   152    (selection.file | selection.division)+
       
   153 
       
   154 
       
   155 # =============================================================================
       
   156 #                                  File level
       
   157 # =============================================================================
       
   158 
       
   159 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   160 
       
   161 composition.file = element file { composition.file.attributes }
       
   162 
       
   163 selection.file = element file { selection.file.attributes }
       
   164 
       
   165 # ~~~~~~ attributes
       
   166 composition.file.attributes =
       
   167    name.attribute
       
   168  & xpath.attribute?
       
   169  & remap.attributes
       
   170 
       
   171 selection.file.attributes =
       
   172    name.attribute
       
   173  & xpath.attribute?
       
   174 
       
   175 name.attribute = attribute name { text }
       
   176 xpath.attribute = attribute xpath { text }
       
   177 
       
   178 
       
   179 # =============================================================================
       
   180 #                                 Inline level
       
   181 # =============================================================================
       
   182 
       
   183 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   184 
       
   185 inlines = mixed {
       
   186    sup*
       
   187  & sub*
       
   188 }
       
   189 
       
   190 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   191 
       
   192 sup = element sup { inlines }
       
   193 
       
   194 sub = element sub { inlines }
       
   195 
       
   196 
       
   197 # =============================================================================
       
   198 #                               Remap attributes
       
   199 # =============================================================================
       
   200 
       
   201 remap.attributes =
       
   202    as.attribute?
       
   203  & attributes.attribute?
       
   204 
       
   205 as.attribute = attribute as { xsd:QName }
       
   206 attributes.attribute =
       
   207    attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}