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