RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
mer., 20 juil. 2011 15:05:37 +0200
changeset 39 7faa356bad3e
parent 38 3c8b406be906
child 40 7cfe2d4957c6
permissions -rw-r--r--
copyright
patrick@0
     1
# $Id$
patrick@0
     2
patrick@0
     3
start = publiset
patrick@0
     4
patrick@0
     5
patrick@0
     6
publiset = element publiset {
patrick@0
     7
   publiset.attributes,
patrick@0
     8
   publiset.content
patrick@0
     9
}
patrick@0
    10
patrick@0
    11
publiset.attributes =
patrick@0
    12
   version.attribute
patrick@0
    13
version.attribute = attribute version { "1.0" }
patrick@0
    14
patrick@0
    15
publiset.content =
patrick@0
    16
   (composition | selection)+
patrick@0
    17
patrick@0
    18
patrick@0
    19
# =============================================================================
patrick@20
    20
#                                  TOP LEVEL
patrick@0
    21
# =============================================================================
patrick@0
    22
patrick@0
    23
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    24
patrick@0
    25
composition = element composition {
patrick@0
    26
   composition.attributes,
patrick@0
    27
   composition.content
patrick@0
    28
}
patrick@0
    29
patrick@0
    30
composition.attributes =
patrick@0
    31
   composition.id.attribute
patrick@29
    32
 & path.attribute?
patrick@29
    33
 & xpath.attribute?
patrick@29
    34
 & xslt.attribute?
patrick@0
    35
 & remap.attributes
patrick@0
    36
composition.id.attribute = attribute xml:id { xsd:ID }
patrick@29
    37
path.attribute = attribute path { xsd:anyURI }
patrick@29
    38
xslt.attribute = attribute xslt { xsd:anyURI }
patrick@29
    39
xpath.attribute = attribute xpath { text }
patrick@0
    40
patrick@0
    41
composition.content =
patrick@20
    42
   composition.head?,
patrick@30
    43
   (composition.division | composition.file)+
patrick@0
    44
patrick@0
    45
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    46
patrick@0
    47
selection = element selection {
patrick@0
    48
   selection.attributes,
patrick@0
    49
   selection.content
patrick@0
    50
}
patrick@0
    51
patrick@0
    52
selection.attributes =
patrick@29
    53
   selection.id.attribute
patrick@29
    54
 & path.attribute?
patrick@0
    55
selection.id.attribute = attribute xml:id { xsd:ID }
patrick@0
    56
patrick@0
    57
selection.content =
patrick@20
    58
   selection.head?,
patrick@30
    59
   (selection.division | selection.file | link)+
patrick@0
    60
patrick@0
    61
patrick@0
    62
# =============================================================================
patrick@20
    63
#                                  HEAD LEVEL
patrick@0
    64
# =============================================================================
patrick@0
    65
patrick@20
    66
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    67
patrick@20
    68
composition.head = element head { head.attributes, top.head.content }
patrick@20
    69
selection.head = element head { top.head.content }
patrick@20
    70
division.head = element head { division.head.content }
patrick@0
    71
patrick@20
    72
head.attributes =
patrick@0
    73
   remap.attributes
patrick@0
    74
patrick@20
    75
top.head.content =
patrick@18
    76
   (title, subtitle?)?
patrick@34
    77
 & identifier*
patrick@18
    78
 & language?
patrick@39
    79
 & copyright?
patrick@5
    80
 & author*
patrick@5
    81
 & publisher?
patrick@5
    82
 & source?
patrick@35
    83
 & cover?
patrick@20
    84
division.head.content =
patrick@20
    85
   (title, subtitle?)?
patrick@20
    86
 & language?
patrick@0
    87
patrick@0
    88
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    89
patrick@0
    90
title = element title { title.content }
patrick@18
    91
subtitle = element subtitle { title.content }
patrick@2
    92
patrick@0
    93
title.content = inlines
patrick@0
    94
patrick@34
    95
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@34
    96
patrick@38
    97
identifier.uri = element identifier {
patrick@38
    98
   attribute type { "uri" }, xsd:anyURI
patrick@38
    99
}
patrick@34
   100
patrick@38
   101
identifier.ean = element identifier {
patrick@38
   102
   attribute type { "ean" }, xsd:token {pattern = "\d{13}"}
patrick@38
   103
}
patrick@34
   104
patrick@38
   105
identifier = identifier.uri | identifier.ean
patrick@34
   106
patrick@18
   107
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ language ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@18
   108
patrick@18
   109
language = element language { language.attributes }
patrick@18
   110
patrick@18
   111
language.attributes = lang.attribute
patrick@18
   112
lang.attribute = attribute xml:lang { xsd:language }
patrick@0
   113
patrick@39
   114
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@39
   115
patrick@39
   116
copyright = element copyright { copyright.content }
patrick@39
   117
patrick@39
   118
copyright.content = inlines
patrick@39
   119
patrick@5
   120
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ author, publisher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   121
patrick@5
   122
# ~~~~~~ author
patrick@5
   123
author = element author { author.content }
patrick@5
   124
patrick@34
   125
author.attributes =
patrick@34
   126
   role.attribute?
patrick@34
   127
role.attribute = attribute role { "author" | "illustrator" }
patrick@34
   128
patrick@5
   129
author.content =
patrick@5
   130
   firstname?,
patrick@34
   131
   lastname,
patrick@34
   132
   role*
patrick@5
   133
patrick@5
   134
# ~~~~~~ publisher
patrick@5
   135
publisher = element publisher { publisher.content }
patrick@5
   136
patrick@34
   137
publisher.content =
patrick@34
   138
   label,
patrick@36
   139
   link?
patrick@5
   140
patrick@5
   141
# ~~~~~~ firstname
patrick@5
   142
firstname = element firstname { firstname.content }
patrick@5
   143
patrick@5
   144
firstname.content = inlines
patrick@5
   145
patrick@5
   146
# ~~~~~~ lastname
patrick@5
   147
lastname = element lastname { lastname.content }
patrick@5
   148
patrick@5
   149
lastname.content = inlines
patrick@5
   150
patrick@34
   151
# ~~~~~~ role
patrick@34
   152
role = element role { role.attributes }
patrick@34
   153
patrick@34
   154
role.attributes =
patrick@34
   155
   role.of.attribute
patrick@34
   156
role.of.attribute = attribute of { "author" | "illustrator" }
patrick@34
   157
patrick@38
   158
# ~~~~~~ label
patrick@38
   159
label = element label { label.content }
patrick@38
   160
patrick@38
   161
label.content = inlines
patrick@38
   162
patrick@0
   163
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   164
patrick@2
   165
# ~~~~~~ source
patrick@0
   166
source = element source {
patrick@0
   167
   (  (attribute type { "book" }, source.content.book)
patrick@38
   168
    | (attribute type { "file" }, source.content.file))
patrick@0
   169
}
patrick@0
   170
patrick@0
   171
source.content.book =
patrick@38
   172
   identifier.ean,
patrick@0
   173
   title?,
patrick@38
   174
   pagenumber*
patrick@38
   175
source.content.file =
patrick@38
   176
   identifier.uri
patrick@0
   177
patrick@2
   178
# ~~~~~~ pagenumber
patrick@0
   179
pagenumber = element pagenumber { pagenumber.attributes }
patrick@2
   180
patrick@0
   181
pagenumber.attributes =
patrick@0
   182
   pagenumber.value.attribute
patrick@0
   183
pagenumber.value.attribute = attribute value { pagenumber.value.enumeration }
patrick@0
   184
pagenumber.value.enumeration = xsd:positiveInteger
patrick@0
   185
patrick@35
   186
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   187
patrick@35
   188
cover = element cover { cover.content }
patrick@35
   189
patrick@35
   190
cover.content =
patrick@35
   191
   cover.image
patrick@35
   192
patrick@35
   193
cover.image = element image { cover.image.attributes }
patrick@35
   194
patrick@35
   195
cover.image.attributes =
patrick@35
   196
   cover.image.id.attribute
patrick@35
   197
cover.image.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   198
patrick@0
   199
patrick@0
   200
# =============================================================================
patrick@20
   201
#                                DIVISION LEVEL
patrick@0
   202
# =============================================================================
patrick@0
   203
patrick@0
   204
composition.division = element division {
patrick@0
   205
   composition.division.attributes,
patrick@0
   206
   composition.division.content
patrick@0
   207
}
patrick@0
   208
selection.division = element division {
patrick@0
   209
   selection.division.attributes,
patrick@0
   210
   selection.division.content
patrick@0
   211
}
patrick@0
   212
patrick@0
   213
composition.division.attributes =
patrick@26
   214
   path.attribute?
patrick@29
   215
 & xpath.attribute?
patrick@23
   216
 & xslt.attribute?
patrick@0
   217
 & remap.attributes
patrick@0
   218
selection.division.attributes =
patrick@26
   219
   path.attribute?
patrick@0
   220
patrick@0
   221
composition.division.content =
patrick@20
   222
   composition.head?,
patrick@20
   223
   (composition.division | composition.file)+
patrick@0
   224
selection.division.content =
patrick@20
   225
   selection.head?,
patrick@30
   226
   (selection.division | selection.file | link)+
patrick@0
   227
patrick@0
   228
patrick@0
   229
# =============================================================================
patrick@20
   230
#                                  FILE LEVEL
patrick@0
   231
# =============================================================================
patrick@0
   232
patrick@0
   233
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   234
patrick@30
   235
composition.file = element file { composition.file.attributes }
patrick@2
   236
selection.file = element file { selection.file.attributes, file.content }
patrick@0
   237
patrick@0
   238
composition.file.attributes =
patrick@30
   239
   name.attribute
patrick@30
   240
 & xpath.attribute?
patrick@29
   241
 & xslt.attribute?
patrick@0
   242
 & remap.attributes
patrick@0
   243
selection.file.attributes =
patrick@30
   244
   name.attribute
patrick@30
   245
 & uri.attribute?
patrick@30
   246
name.attribute = attribute name { xsd:anyURI }
patrick@0
   247
patrick@30
   248
file.content = inlines
patrick@30
   249
patrick@30
   250
patrick@0
   251
# =============================================================================
patrick@20
   252
#                                 INLINE LEVEL
patrick@0
   253
# =============================================================================
patrick@0
   254
patrick@0
   255
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   256
patrick@0
   257
inlines = mixed {
patrick@0
   258
   sup*
patrick@0
   259
 & sub*
patrick@0
   260
}
patrick@0
   261
patrick@0
   262
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   263
patrick@0
   264
sup = element sup { inlines }
patrick@0
   265
patrick@0
   266
sub = element sub { inlines }
patrick@0
   267
patrick@36
   268
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   269
patrick@36
   270
link = element link { link.attributes, link.content }
patrick@36
   271
patrick@36
   272
link.attributes =
patrick@36
   273
   uri.attribute
patrick@36
   274
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   275
patrick@36
   276
link.content = inlines
patrick@36
   277
patrick@0
   278
patrick@0
   279
# =============================================================================
patrick@20
   280
#                               REMAP ATTRIBUTES
patrick@0
   281
# =============================================================================
patrick@0
   282
patrick@0
   283
remap.attributes =
patrick@0
   284
   as.attribute?
patrick@0
   285
 & attributes.attribute?
patrick@0
   286
as.attribute = attribute as { xsd:QName }
patrick@0
   287
attributes.attribute =
patrick@0
   288
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}