RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
ven., 27 avril 2012 19:13:50 +0200
changeset 96 4817d2fa8801
parent 66 29c53c3d676e
child 97 e28caa4cbf4c
permissions -rw-r--r--
Attribut transform
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@29
    34
 & xpath.attribute?
patrick@29
    35
 & xslt.attribute?
patrick@0
    36
 & remap.attributes
patrick@66
    37
 & lang.attribute?
patrick@0
    38
composition.id.attribute = attribute xml:id { xsd:ID }
patrick@29
    39
path.attribute = attribute path { xsd:anyURI }
patrick@29
    40
xslt.attribute = attribute xslt { xsd:anyURI }
patrick@29
    41
xpath.attribute = attribute xpath { text }
patrick@66
    42
lang.attribute = attribute xml:lang { xsd:language }
patrick@0
    43
patrick@0
    44
composition.content =
patrick@20
    45
   composition.head?,
patrick@30
    46
   (composition.division | composition.file)+
patrick@0
    47
patrick@96
    48
# ~~~~~~ composition.head
patrick@96
    49
composition.head = element head {
patrick@96
    50
   composition.head.attributes, composition.head.content }
patrick@96
    51
patrick@96
    52
composition.head.attributes =
patrick@96
    53
   remap.attributes
patrick@96
    54
patrick@96
    55
composition.head.content =
patrick@96
    56
   (title, subtitle?)?
patrick@96
    57
 & identifier*
patrick@96
    58
 & copyright?
patrick@96
    59
 & contributors?
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@0
    75
selection.id.attribute = attribute xml:id { xsd:ID }
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@96
    89
# ~~~~~~ division
patrick@96
    90
composition.division = element division {
patrick@96
    91
   composition.division.attributes,
patrick@96
    92
   composition.division.content
patrick@96
    93
}
patrick@96
    94
selection.division = element division {
patrick@96
    95
   selection.division.attributes,
patrick@96
    96
   selection.division.content
patrick@96
    97
}
patrick@96
    98
patrick@96
    99
composition.division.attributes =
patrick@96
   100
   path.attribute?
patrick@96
   101
 & xpath.attribute?
patrick@96
   102
 & xslt.attribute?
patrick@96
   103
 & transform.attribute?
patrick@96
   104
 & remap.attributes
patrick@96
   105
selection.division.attributes =
patrick@96
   106
   path.attribute?
patrick@96
   107
transform.attribute = attribute transform { xsd:anyURI }
patrick@96
   108
patrick@96
   109
composition.division.content =
patrick@96
   110
   composition.head?,
patrick@96
   111
   (composition.division | composition.file)+
patrick@96
   112
selection.division.content =
patrick@96
   113
   selection.head?,
patrick@96
   114
   (selection.division | selection.file | link)+
patrick@96
   115
patrick@96
   116
# ~~~~~~ division.head
patrick@96
   117
division.head = element head { division.head.content }
patrick@96
   118
patrick@96
   119
division.head.content =
patrick@96
   120
   (title, subtitle?)?
patrick@96
   121
patrick@96
   122
patrick@96
   123
# =============================================================================
patrick@96
   124
#                                  FILE LEVEL
patrick@96
   125
# =============================================================================
patrick@96
   126
patrick@96
   127
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@96
   128
patrick@96
   129
composition.file = element file { composition.file.attributes }
patrick@96
   130
selection.file = element file { selection.file.attributes, file.content }
patrick@96
   131
patrick@96
   132
composition.file.attributes =
patrick@96
   133
   name.attribute
patrick@96
   134
 & xpath.attribute?
patrick@96
   135
 & xslt.attribute?
patrick@96
   136
selection.file.attributes =
patrick@96
   137
   name.attribute
patrick@96
   138
 & uri.attribute?
patrick@96
   139
name.attribute = attribute name { xsd:anyURI }
patrick@96
   140
patrick@96
   141
file.content = inlines
patrick@96
   142
patrick@96
   143
patrick@96
   144
# =============================================================================
patrick@96
   145
#                                 BLOCK LEVEL
patrick@96
   146
# =============================================================================
patrick@96
   147
patrick@96
   148
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@96
   149
patrick@96
   150
p = element p { p.content }
patrick@96
   151
patrick@96
   152
p.content =
patrick@96
   153
   inlines
patrick@96
   154
patrick@0
   155
patrick@0
   156
# =============================================================================
patrick@20
   157
#                                  HEAD LEVEL
patrick@0
   158
# =============================================================================
patrick@0
   159
patrick@0
   160
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   161
patrick@0
   162
title = element title { title.content }
patrick@18
   163
subtitle = element subtitle { title.content }
patrick@2
   164
patrick@0
   165
title.content = inlines
patrick@0
   166
patrick@34
   167
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@34
   168
patrick@38
   169
identifier.uri = element identifier {
patrick@38
   170
   attribute type { "uri" }, xsd:anyURI
patrick@38
   171
}
patrick@34
   172
patrick@38
   173
identifier.ean = element identifier {
patrick@38
   174
   attribute type { "ean" }, xsd:token {pattern = "\d{13}"}
patrick@38
   175
}
patrick@34
   176
patrick@38
   177
identifier = identifier.uri | identifier.ean
patrick@34
   178
patrick@39
   179
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@39
   180
patrick@39
   181
copyright = element copyright { copyright.content }
patrick@39
   182
patrick@39
   183
copyright.content = inlines
patrick@39
   184
patrick@66
   185
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   186
patrick@66
   187
# ~~~~~~ contributors
patrick@66
   188
contributors = element contributors { contributors.content }
patrick@5
   189
patrick@66
   190
contributors.content =
patrick@66
   191
   contributor+
patrick@34
   192
patrick@66
   193
# ~~~~~~ contributor
patrick@66
   194
contributor = element contributor { contributor.content }
patrick@66
   195
patrick@66
   196
contributor.content =
patrick@66
   197
   (((firstname, secondname?)?, lastname) | label),
patrick@66
   198
   address?,
patrick@66
   199
   link?,
patrick@34
   200
   role*
patrick@5
   201
patrick@66
   202
# ~~~~~~ firstname, secondname, lastname, label
patrick@5
   203
firstname = element firstname { firstname.content }
patrick@66
   204
secondname = element secondname { secondname.content }
patrick@66
   205
lastname = element lastname { lastname.content }
patrick@66
   206
label = element label { label.content }
patrick@5
   207
patrick@5
   208
firstname.content = inlines
patrick@66
   209
secondname.content = inlines
patrick@66
   210
lastname.content = inlines
patrick@66
   211
label.content = inlines
patrick@5
   212
patrick@66
   213
# ~~~~~~ address
patrick@66
   214
address = element address { address.content }
patrick@5
   215
patrick@66
   216
address.content = inlines
patrick@5
   217
patrick@34
   218
# ~~~~~~ role
patrick@66
   219
role = element role { role.content }
patrick@34
   220
patrick@66
   221
role.content = "author" | "illustrator" | "publisher"
patrick@38
   222
yvon@52
   223
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   224
yvon@52
   225
abstract = element abstract { abstract.content }
yvon@52
   226
yvon@52
   227
abstract.content =
yvon@52
   228
   p+
yvon@52
   229
patrick@35
   230
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   231
patrick@35
   232
cover = element cover { cover.content }
patrick@35
   233
patrick@35
   234
cover.content =
patrick@35
   235
   cover.image
patrick@35
   236
patrick@35
   237
cover.image = element image { cover.image.attributes }
patrick@35
   238
patrick@35
   239
cover.image.attributes =
patrick@35
   240
   cover.image.id.attribute
patrick@35
   241
cover.image.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   242
patrick@0
   243
patrick@0
   244
# =============================================================================
patrick@20
   245
#                                 INLINE LEVEL
patrick@0
   246
# =============================================================================
patrick@0
   247
patrick@0
   248
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   249
patrick@0
   250
inlines = mixed {
patrick@0
   251
   sup*
patrick@0
   252
 & sub*
patrick@0
   253
}
patrick@0
   254
patrick@0
   255
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   256
patrick@0
   257
sup = element sup { inlines }
patrick@0
   258
patrick@0
   259
sub = element sub { inlines }
patrick@0
   260
patrick@36
   261
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   262
patrick@36
   263
link = element link { link.attributes, link.content }
patrick@36
   264
patrick@36
   265
link.attributes =
patrick@36
   266
   uri.attribute
patrick@36
   267
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   268
patrick@36
   269
link.content = inlines
patrick@36
   270
patrick@0
   271
patrick@0
   272
# =============================================================================
patrick@20
   273
#                               REMAP ATTRIBUTES
patrick@0
   274
# =============================================================================
patrick@0
   275
patrick@0
   276
remap.attributes =
patrick@0
   277
   as.attribute?
patrick@0
   278
 & attributes.attribute?
patrick@0
   279
as.attribute = attribute as { xsd:QName }
patrick@0
   280
attributes.attribute =
patrick@0
   281
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}