RelaxNG/publiset.rnc
author Patrick PIERRE
jeu., 20 déc. 2012 15:10:18 +0100
changeset 152 fddb2b67c19c
parent 127 efce69890bfd
child 155 1568fa18df9e
permissions -rw-r--r--
xpath et xslt exclusif
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@96
    25
# ~~~~~~ composition
patrick@0
    26
composition = element composition {
patrick@0
    27
   composition.attributes,
patrick@0
    28
   composition.content
patrick@0
    29
}
patrick@0
    30
patrick@0
    31
composition.attributes =
patrick@0
    32
   composition.id.attribute
patrick@29
    33
 & path.attribute?
Patrick@152
    34
 & (xpath.attribute | xslt.attribute)?
patrick@0
    35
 & remap.attributes
patrick@66
    36
 & lang.attribute?
patrick@117
    37
composition.id.attribute = attribute id { xsd:NMTOKEN }
patrick@29
    38
path.attribute = attribute path { xsd:anyURI }
patrick@29
    39
xslt.attribute = attribute xslt { xsd:anyURI }
patrick@29
    40
xpath.attribute = attribute xpath { text }
patrick@66
    41
lang.attribute = attribute xml:lang { xsd:language }
patrick@0
    42
patrick@0
    43
composition.content =
patrick@20
    44
   composition.head?,
patrick@30
    45
   (composition.division | composition.file)+
patrick@0
    46
patrick@96
    47
# ~~~~~~ composition.head
patrick@96
    48
composition.head = element head {
patrick@96
    49
   composition.head.attributes, composition.head.content }
patrick@96
    50
patrick@96
    51
composition.head.attributes =
patrick@96
    52
   remap.attributes
patrick@96
    53
patrick@96
    54
composition.head.content =
patrick@127
    55
   (title, shorttitle?, subtitle?)?
patrick@96
    56
 & identifier*
patrick@96
    57
 & copyright?
patrick@96
    58
 & contributors?
patrick@98
    59
 & keywordset?
patrick@96
    60
 & abstract?
patrick@96
    61
 & cover?
patrick@96
    62
patrick@0
    63
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    64
patrick@96
    65
# ~~~~~~ selection
patrick@0
    66
selection = element selection {
patrick@0
    67
   selection.attributes,
patrick@0
    68
   selection.content
patrick@0
    69
}
patrick@0
    70
patrick@0
    71
selection.attributes =
patrick@29
    72
   selection.id.attribute
patrick@29
    73
 & path.attribute?
patrick@66
    74
 & lang.attribute?
patrick@117
    75
selection.id.attribute = attribute id { xsd:NMTOKEN }
patrick@0
    76
patrick@0
    77
selection.content =
patrick@20
    78
   selection.head?,
patrick@30
    79
   (selection.division | selection.file | link)+
patrick@0
    80
patrick@96
    81
# ~~~~~~ selection.head
patrick@96
    82
selection.head = element head { composition.head.content }
patrick@96
    83
patrick@96
    84
patrick@96
    85
# =============================================================================
patrick@96
    86
#                                DIVISION LEVEL
patrick@96
    87
# =============================================================================
patrick@96
    88
patrick@98
    89
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@98
    90
patrick@96
    91
# ~~~~~~ division
patrick@96
    92
composition.division = element division {
patrick@96
    93
   composition.division.attributes,
patrick@96
    94
   composition.division.content
patrick@96
    95
}
patrick@96
    96
selection.division = element division {
patrick@96
    97
   selection.division.attributes,
patrick@96
    98
   selection.division.content
patrick@96
    99
}
patrick@96
   100
patrick@96
   101
composition.division.attributes =
patrick@96
   102
   path.attribute?
Patrick@152
   103
 & (xpath.attribute | xslt.attribute)?
patrick@96
   104
 & remap.attributes
patrick@96
   105
selection.division.attributes =
patrick@96
   106
   path.attribute?
patrick@96
   107
patrick@96
   108
composition.division.content =
patrick@96
   109
   composition.head?,
patrick@96
   110
   (composition.division | composition.file)+
patrick@96
   111
selection.division.content =
patrick@96
   112
   selection.head?,
patrick@96
   113
   (selection.division | selection.file | link)+
patrick@96
   114
patrick@96
   115
# ~~~~~~ division.head
patrick@96
   116
division.head = element head { division.head.content }
patrick@96
   117
patrick@96
   118
division.head.content =
patrick@127
   119
   (title, shorttitle?, subtitle?)?
patrick@96
   120
patrick@96
   121
patrick@96
   122
# =============================================================================
patrick@96
   123
#                                  FILE LEVEL
patrick@96
   124
# =============================================================================
patrick@96
   125
patrick@96
   126
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@96
   127
patrick@96
   128
composition.file = element file { composition.file.attributes }
patrick@96
   129
selection.file = element file { selection.file.attributes, file.content }
patrick@96
   130
patrick@96
   131
composition.file.attributes =
patrick@96
   132
   name.attribute
Patrick@152
   133
 & (xpath.attribute | xslt.attribute)?
patrick@96
   134
selection.file.attributes =
patrick@96
   135
   name.attribute
patrick@96
   136
 & uri.attribute?
patrick@96
   137
name.attribute = attribute name { xsd:anyURI }
patrick@96
   138
patrick@96
   139
file.content = inlines
patrick@96
   140
patrick@96
   141
patrick@96
   142
# =============================================================================
patrick@96
   143
#                                 BLOCK LEVEL
patrick@96
   144
# =============================================================================
patrick@96
   145
patrick@96
   146
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@96
   147
patrick@96
   148
p = element p { p.content }
patrick@96
   149
patrick@96
   150
p.content =
patrick@96
   151
   inlines
patrick@96
   152
patrick@0
   153
patrick@0
   154
# =============================================================================
patrick@20
   155
#                                  HEAD LEVEL
patrick@0
   156
# =============================================================================
patrick@0
   157
patrick@0
   158
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   159
patrick@0
   160
title = element title { title.content }
patrick@127
   161
shorttitle = element shorttitle { title.content }
patrick@18
   162
subtitle = element subtitle { title.content }
patrick@2
   163
patrick@0
   164
title.content = inlines
patrick@0
   165
patrick@34
   166
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@34
   167
patrick@38
   168
identifier.uri = element identifier {
patrick@38
   169
   attribute type { "uri" }, xsd:anyURI
patrick@38
   170
}
patrick@34
   171
patrick@38
   172
identifier.ean = element identifier {
patrick@38
   173
   attribute type { "ean" }, xsd:token {pattern = "\d{13}"}
patrick@38
   174
}
patrick@34
   175
patrick@38
   176
identifier = identifier.uri | identifier.ean
patrick@34
   177
patrick@39
   178
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@39
   179
patrick@39
   180
copyright = element copyright { copyright.content }
patrick@39
   181
patrick@39
   182
copyright.content = inlines
patrick@39
   183
patrick@66
   184
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   185
patrick@66
   186
# ~~~~~~ contributors
patrick@66
   187
contributors = element contributors { contributors.content }
patrick@5
   188
patrick@66
   189
contributors.content =
patrick@66
   190
   contributor+
patrick@34
   191
patrick@66
   192
# ~~~~~~ contributor
patrick@66
   193
contributor = element contributor { contributor.content }
patrick@66
   194
patrick@66
   195
contributor.content =
patrick@66
   196
   (((firstname, secondname?)?, lastname) | label),
patrick@66
   197
   address?,
patrick@66
   198
   link?,
patrick@101
   199
   role+
patrick@5
   200
patrick@66
   201
# ~~~~~~ firstname, secondname, lastname, label
patrick@5
   202
firstname = element firstname { firstname.content }
patrick@66
   203
secondname = element secondname { secondname.content }
patrick@66
   204
lastname = element lastname { lastname.content }
patrick@66
   205
label = element label { label.content }
patrick@5
   206
patrick@5
   207
firstname.content = inlines
patrick@66
   208
secondname.content = inlines
patrick@66
   209
lastname.content = inlines
patrick@66
   210
label.content = inlines
patrick@5
   211
patrick@66
   212
# ~~~~~~ address
patrick@66
   213
address = element address { address.content }
patrick@5
   214
patrick@66
   215
address.content = inlines
patrick@5
   216
patrick@34
   217
# ~~~~~~ role
patrick@66
   218
role = element role { role.content }
patrick@34
   219
patrick@101
   220
role.content = "author" | "illustrator" | "publisher" | "packager"
patrick@38
   221
patrick@98
   222
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keyword ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@98
   223
patrick@98
   224
# ~~~~~~ keywordset
patrick@98
   225
keywordset = element keywordset { keywordset.content }
patrick@98
   226
patrick@98
   227
keywordset.content = keyword+
patrick@98
   228
patrick@98
   229
# ~~~~~~ keyword
patrick@98
   230
keyword = element keyword { keyword.content }
patrick@98
   231
patrick@98
   232
keyword.content = mixed { sup*, sub* }
patrick@98
   233
yvon@52
   234
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   235
yvon@52
   236
abstract = element abstract { abstract.content }
yvon@52
   237
yvon@52
   238
abstract.content =
yvon@52
   239
   p+
yvon@52
   240
patrick@35
   241
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   242
patrick@35
   243
cover = element cover { cover.content }
patrick@35
   244
patrick@35
   245
cover.content =
patrick@35
   246
   cover.image
patrick@35
   247
patrick@35
   248
cover.image = element image { cover.image.attributes }
patrick@35
   249
patrick@35
   250
cover.image.attributes =
patrick@35
   251
   cover.image.id.attribute
patrick@35
   252
cover.image.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   253
patrick@0
   254
patrick@0
   255
# =============================================================================
patrick@20
   256
#                                 INLINE LEVEL
patrick@0
   257
# =============================================================================
patrick@0
   258
patrick@0
   259
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   260
patrick@0
   261
inlines = mixed {
patrick@0
   262
   sup*
patrick@0
   263
 & sub*
patrick@126
   264
 & name*
patrick@126
   265
 & highlight*
patrick@0
   266
}
patrick@0
   267
patrick@0
   268
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   269
patrick@0
   270
sup = element sup { inlines }
patrick@0
   271
patrick@0
   272
sub = element sub { inlines }
patrick@0
   273
patrick@126
   274
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   275
patrick@126
   276
name = element name { name.attributes, name.content }
patrick@126
   277
patrick@126
   278
name.attributes =
patrick@126
   279
   name.of.attribute?
patrick@126
   280
name.of.attribute = attribute of
patrick@126
   281
   { "person" | "company" | "book" | "newspaper" | "party" }
patrick@126
   282
patrick@126
   283
name.content = inlines
patrick@126
   284
patrick@126
   285
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   286
patrick@126
   287
highlight = element highlight { highlight.content }
patrick@126
   288
patrick@126
   289
highlight.content = inlines
patrick@126
   290
patrick@36
   291
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   292
patrick@36
   293
link = element link { link.attributes, link.content }
patrick@36
   294
patrick@36
   295
link.attributes =
patrick@36
   296
   uri.attribute
patrick@36
   297
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   298
patrick@36
   299
link.content = inlines
patrick@36
   300
patrick@0
   301
patrick@0
   302
# =============================================================================
patrick@20
   303
#                               REMAP ATTRIBUTES
patrick@0
   304
# =============================================================================
patrick@0
   305
patrick@0
   306
remap.attributes =
patrick@0
   307
   as.attribute?
patrick@0
   308
 & attributes.attribute?
patrick@97
   309
 & transform.attribute?
patrick@0
   310
as.attribute = attribute as { xsd:QName }
patrick@0
   311
attributes.attribute =
patrick@0
   312
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
patrick@97
   313
transform.attribute = attribute transform { xsd:anyURI }