RelaxNG/publiset.rnc
changeset 310 13939fb7824a
parent 293 02671b229bdc
child 313 e4f154ea2837
equal deleted inserted replaced
309:b748affd5db2 310:13939fb7824a
    12    version.attribute
    12    version.attribute
    13 version.attribute = attribute version { "1.0" }
    13 version.attribute = attribute version { "1.0" }
    14 
    14 
    15 publiset.content =
    15 publiset.content =
    16    (composition | selection)+
    16    (composition | selection)+
       
    17 
       
    18 
       
    19 
       
    20 # =============================================================================
       
    21 #                                  HEAD LEVEL
       
    22 # =============================================================================
       
    23 
       
    24 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    25 
       
    26 title = element title { title.content }
       
    27 shorttitle = element shorttitle { title.content }
       
    28 subtitle = element subtitle { title.content }
       
    29 
       
    30 title.content = inlines
       
    31 
       
    32 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    33 
       
    34 # ~~~~~~ identifier
       
    35 identifier = element identifier {
       
    36    (attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"})
       
    37  | (attribute type { "uri" }, for.attribute?, xsd:anyURI)
       
    38 }
       
    39 
       
    40 for.attribute = attribute for { xsd:NCName }
       
    41 
       
    42 # ~~~~~~ identifier.ean
       
    43 identifier.ean = element identifier {
       
    44    attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"}
       
    45 }
       
    46 
       
    47 # ~~~~~~ identifier.uri
       
    48 identifier.uri = element identifier {
       
    49    attribute type { "uri" }, for.attribute?, xsd:anyURI
       
    50 }
       
    51 
       
    52 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    53 
       
    54 copyright = element copyright { copyright.content }
       
    55 
       
    56 copyright.content = simple.inlines
       
    57 
       
    58 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    59 
       
    60 collection = element collection { collection.content }
       
    61 
       
    62 collection.content = simple.inlines
       
    63 
       
    64 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    65 
       
    66 # ~~~~~~ contributors
       
    67 contributors = element contributors { contributors.content }
       
    68 
       
    69 contributors.content =
       
    70    contributor+
       
    71 
       
    72 # ~~~~~~ contributor
       
    73 contributor = element contributor { contributor.content }
       
    74 
       
    75 contributor.content =
       
    76    identifier.uri?,
       
    77    (((firstname, secondname?)?, lastname) | label),
       
    78    address?,
       
    79    link?,
       
    80    role+
       
    81 
       
    82 # ~~~~~~ firstname, secondname, lastname, label
       
    83 firstname = element firstname { firstname.content }
       
    84 secondname = element secondname { secondname.content }
       
    85 lastname = element lastname { lastname.content }
       
    86 label = element label { label.content }
       
    87 
       
    88 firstname.content = simple.inlines
       
    89 secondname.content = simple.inlines
       
    90 lastname.content = simple.inlines
       
    91 label.content = simple.inlines
       
    92 
       
    93 # ~~~~~~ address
       
    94 address = element address { address.content }
       
    95 
       
    96 address.content = simple.inlines
       
    97 
       
    98 # ~~~~~~ role
       
    99 role = element role { role.content }
       
   100 
       
   101 role.content = "author" | "illustrator" | "publisher" | "packager"
       
   102 
       
   103 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   104 
       
   105 source = element source {
       
   106    (  (attribute type { "book" }, source.content.book)
       
   107     | (attribute type { "file" }, source.content.file))
       
   108 }
       
   109 
       
   110 source.content.book =
       
   111    identifier.ean?
       
   112  & title
       
   113  & subtitle?
       
   114  & copyright?
       
   115  & collection?
       
   116  & folio?
       
   117  & pages?
       
   118  
       
   119 source.content.file =
       
   120    identifier.uri
       
   121 
       
   122 # ~~~~~~ folio
       
   123 folio = element folio { folio.content }
       
   124 
       
   125 folio.content = xsd:positiveInteger | xsd:token {pattern = "[DLXVI]+"}
       
   126 
       
   127 # ~~~~~~ pages
       
   128 pages = element pages { pages.content }
       
   129 
       
   130 pages.content = xsd:positiveInteger
       
   131 
       
   132 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keyword & subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   133 
       
   134 # ~~~~~~ keywordset
       
   135 keywordset = element keywordset { keywordset.content }
       
   136 
       
   137 keywordset.content = keyword+
       
   138 
       
   139 # ~~~~~~ keyword
       
   140 keyword = element keyword { keyword.content }
       
   141 
       
   142 keyword.content = simple.inlines
       
   143 
       
   144 # ~~~~~~ subjectset
       
   145 subjectset = element subjectset { subjectset.content }
       
   146 
       
   147 subjectset.content = subject+
       
   148 
       
   149 # ~~~~~~ subject
       
   150 subject = element subject { subject.content }
       
   151 
       
   152 subject.content = simple.inlines
       
   153 
       
   154 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   155 
       
   156 # ~~~~~~ index
       
   157 head.index = element index { head.index.content }
       
   158 
       
   159 head.index.content =
       
   160    index.entry, index.entry?
       
   161 
       
   162 # ~~~~~~ index.entry
       
   163 index.entry = element entry { simple.inlines }
       
   164 
       
   165 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   166 
       
   167 abstract = element abstract { abstract.content }
       
   168 
       
   169 abstract.content =
       
   170    p+
       
   171 
       
   172 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   173 
       
   174 cover = element cover { cover.content }
       
   175 
       
   176 cover.content =
       
   177    cover.image
       
   178 
       
   179 cover.image = element image { cover.image.attributes }
       
   180 
       
   181 cover.image.attributes =
       
   182    media.id.attribute
       
   183 media.id.attribute = attribute id { xsd:NMTOKEN }
    17 
   184 
    18 
   185 
    19 # =============================================================================
   186 # =============================================================================
    20 #                                  TOP LEVEL
   187 #                                  TOP LEVEL
    21 # =============================================================================
   188 # =============================================================================
   156 p.content =
   323 p.content =
   157    inlines
   324    inlines
   158 
   325 
   159 
   326 
   160 # =============================================================================
   327 # =============================================================================
   161 #                                  HEAD LEVEL
       
   162 # =============================================================================
       
   163 
       
   164 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   165 
       
   166 title = element title { title.content }
       
   167 shorttitle = element shorttitle { title.content }
       
   168 subtitle = element subtitle { title.content }
       
   169 
       
   170 title.content = inlines
       
   171 
       
   172 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   173 
       
   174 # ~~~~~~ identifier
       
   175 identifier = element identifier {
       
   176    (attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"})
       
   177  | (attribute type { "uri" }, for.attribute?, xsd:anyURI)
       
   178 }
       
   179 
       
   180 for.attribute = attribute for { xsd:NCName }
       
   181 
       
   182 # ~~~~~~ identifier.ean
       
   183 identifier.ean = element identifier {
       
   184    attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"}
       
   185 }
       
   186 
       
   187 # ~~~~~~ identifier.uri
       
   188 identifier.uri = element identifier {
       
   189    attribute type { "uri" }, for.attribute?, xsd:anyURI
       
   190 }
       
   191 
       
   192 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   193 
       
   194 copyright = element copyright { copyright.content }
       
   195 
       
   196 copyright.content = simple.inlines
       
   197 
       
   198 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   199 
       
   200 collection = element collection { collection.content }
       
   201 
       
   202 collection.content = simple.inlines
       
   203 
       
   204 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   205 
       
   206 # ~~~~~~ contributors
       
   207 contributors = element contributors { contributors.content }
       
   208 
       
   209 contributors.content =
       
   210    contributor+
       
   211 
       
   212 # ~~~~~~ contributor
       
   213 contributor = element contributor { contributor.content }
       
   214 
       
   215 contributor.content =
       
   216    identifier.uri?,
       
   217    (((firstname, secondname?)?, lastname) | label),
       
   218    address?,
       
   219    link?,
       
   220    role+
       
   221 
       
   222 # ~~~~~~ firstname, secondname, lastname, label
       
   223 firstname = element firstname { firstname.content }
       
   224 secondname = element secondname { secondname.content }
       
   225 lastname = element lastname { lastname.content }
       
   226 label = element label { label.content }
       
   227 
       
   228 firstname.content = simple.inlines
       
   229 secondname.content = simple.inlines
       
   230 lastname.content = simple.inlines
       
   231 label.content = simple.inlines
       
   232 
       
   233 # ~~~~~~ address
       
   234 address = element address { address.content }
       
   235 
       
   236 address.content = simple.inlines
       
   237 
       
   238 # ~~~~~~ role
       
   239 role = element role { role.content }
       
   240 
       
   241 role.content = "author" | "illustrator" | "publisher" | "packager"
       
   242 
       
   243 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   244 
       
   245 source = element source {
       
   246    (  (attribute type { "book" }, source.content.book)
       
   247     | (attribute type { "file" }, source.content.file))
       
   248 }
       
   249 
       
   250 source.content.book =
       
   251    identifier.ean?
       
   252  & title
       
   253  & subtitle?
       
   254  & copyright?
       
   255  & collection?
       
   256  & folio?
       
   257  & pages?
       
   258  
       
   259 source.content.file =
       
   260    identifier.uri
       
   261 
       
   262 # ~~~~~~ folio
       
   263 folio = element folio { folio.content }
       
   264 
       
   265 folio.content = xsd:positiveInteger | xsd:token {pattern = "[DLXVI]+"}
       
   266 
       
   267 # ~~~~~~ pages
       
   268 pages = element pages { pages.content }
       
   269 
       
   270 pages.content = xsd:positiveInteger
       
   271 
       
   272 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keyword & subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   273 
       
   274 # ~~~~~~ keywordset
       
   275 keywordset = element keywordset { keywordset.content }
       
   276 
       
   277 keywordset.content = keyword+
       
   278 
       
   279 # ~~~~~~ keyword
       
   280 keyword = element keyword { keyword.content }
       
   281 
       
   282 keyword.content = simple.inlines
       
   283 
       
   284 # ~~~~~~ subjectset
       
   285 subjectset = element subjectset { subjectset.content }
       
   286 
       
   287 subjectset.content = subject+
       
   288 
       
   289 # ~~~~~~ subject
       
   290 subject = element subject { subject.content }
       
   291 
       
   292 subject.content = simple.inlines
       
   293 
       
   294 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   295 
       
   296 # ~~~~~~ index
       
   297 head.index = element index { head.index.content }
       
   298 
       
   299 head.index.content =
       
   300    index.entry, index.entry?
       
   301 
       
   302 # ~~~~~~ index.entry
       
   303 index.entry = element entry { simple.inlines }
       
   304 
       
   305 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   306 
       
   307 abstract = element abstract { abstract.content }
       
   308 
       
   309 abstract.content =
       
   310    p+
       
   311 
       
   312 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   313 
       
   314 cover = element cover { cover.content }
       
   315 
       
   316 cover.content =
       
   317    cover.image
       
   318 
       
   319 cover.image = element image { cover.image.attributes }
       
   320 
       
   321 cover.image.attributes =
       
   322    media.id.attribute
       
   323 media.id.attribute = attribute id { xsd:NMTOKEN }
       
   324 
       
   325 
       
   326 # =============================================================================
       
   327 #                                 INLINE LEVEL
   328 #                                 INLINE LEVEL
   328 # =============================================================================
   329 # =============================================================================
   329 
   330 
   330 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   331 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   331 
   332