RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
lun., 23 janv. 2012 18:59:27 +0100
changeset 77 4690abab3daa
parent 66 29c53c3d676e
child 96 4817d2fa8801
permissions -rw-r--r--
Structuration des exercices composites
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@66
    36
 & lang.attribute?
patrick@0
    37
composition.id.attribute = attribute xml:id { xsd:ID }
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@0
    47
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    48
patrick@0
    49
selection = element selection {
patrick@0
    50
   selection.attributes,
patrick@0
    51
   selection.content
patrick@0
    52
}
patrick@0
    53
patrick@0
    54
selection.attributes =
patrick@29
    55
   selection.id.attribute
patrick@29
    56
 & path.attribute?
patrick@66
    57
 & lang.attribute?
patrick@0
    58
selection.id.attribute = attribute xml:id { xsd:ID }
patrick@0
    59
patrick@0
    60
selection.content =
patrick@20
    61
   selection.head?,
patrick@30
    62
   (selection.division | selection.file | link)+
patrick@0
    63
patrick@0
    64
patrick@0
    65
# =============================================================================
patrick@20
    66
#                                  HEAD LEVEL
patrick@0
    67
# =============================================================================
patrick@0
    68
patrick@20
    69
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    70
patrick@20
    71
composition.head = element head { head.attributes, top.head.content }
patrick@20
    72
selection.head = element head { top.head.content }
patrick@20
    73
division.head = element head { division.head.content }
patrick@0
    74
patrick@20
    75
head.attributes =
patrick@0
    76
   remap.attributes
patrick@0
    77
patrick@20
    78
top.head.content =
patrick@18
    79
   (title, subtitle?)?
patrick@34
    80
 & identifier*
patrick@39
    81
 & copyright?
patrick@66
    82
 & contributors?
yvon@52
    83
 & abstract?
patrick@35
    84
 & cover?
patrick@20
    85
division.head.content =
patrick@20
    86
   (title, subtitle?)?
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@39
   107
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@39
   108
patrick@39
   109
copyright = element copyright { copyright.content }
patrick@39
   110
patrick@39
   111
copyright.content = inlines
patrick@39
   112
patrick@66
   113
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   114
patrick@66
   115
# ~~~~~~ contributors
patrick@66
   116
contributors = element contributors { contributors.content }
patrick@5
   117
patrick@66
   118
contributors.content =
patrick@66
   119
   contributor+
patrick@34
   120
patrick@66
   121
# ~~~~~~ contributor
patrick@66
   122
contributor = element contributor { contributor.content }
patrick@66
   123
patrick@66
   124
contributor.content =
patrick@66
   125
   (((firstname, secondname?)?, lastname) | label),
patrick@66
   126
   address?,
patrick@66
   127
   link?,
patrick@34
   128
   role*
patrick@5
   129
patrick@66
   130
# ~~~~~~ firstname, secondname, lastname, label
patrick@5
   131
firstname = element firstname { firstname.content }
patrick@66
   132
secondname = element secondname { secondname.content }
patrick@66
   133
lastname = element lastname { lastname.content }
patrick@66
   134
label = element label { label.content }
patrick@5
   135
patrick@5
   136
firstname.content = inlines
patrick@66
   137
secondname.content = inlines
patrick@66
   138
lastname.content = inlines
patrick@66
   139
label.content = inlines
patrick@5
   140
patrick@66
   141
# ~~~~~~ address
patrick@66
   142
address = element address { address.content }
patrick@5
   143
patrick@66
   144
address.content = inlines
patrick@5
   145
patrick@34
   146
# ~~~~~~ role
patrick@66
   147
role = element role { role.content }
patrick@34
   148
patrick@66
   149
role.content = "author" | "illustrator" | "publisher"
patrick@38
   150
yvon@52
   151
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   152
yvon@52
   153
abstract = element abstract { abstract.content }
yvon@52
   154
yvon@52
   155
abstract.content =
yvon@52
   156
   p+
yvon@52
   157
patrick@35
   158
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   159
patrick@35
   160
cover = element cover { cover.content }
patrick@35
   161
patrick@35
   162
cover.content =
patrick@35
   163
   cover.image
patrick@35
   164
patrick@35
   165
cover.image = element image { cover.image.attributes }
patrick@35
   166
patrick@35
   167
cover.image.attributes =
patrick@35
   168
   cover.image.id.attribute
patrick@35
   169
cover.image.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   170
patrick@0
   171
patrick@0
   172
# =============================================================================
patrick@20
   173
#                                DIVISION LEVEL
patrick@0
   174
# =============================================================================
patrick@0
   175
patrick@0
   176
composition.division = element division {
patrick@0
   177
   composition.division.attributes,
patrick@0
   178
   composition.division.content
patrick@0
   179
}
patrick@0
   180
selection.division = element division {
patrick@0
   181
   selection.division.attributes,
patrick@0
   182
   selection.division.content
patrick@0
   183
}
patrick@0
   184
patrick@0
   185
composition.division.attributes =
patrick@26
   186
   path.attribute?
patrick@29
   187
 & xpath.attribute?
patrick@23
   188
 & xslt.attribute?
patrick@0
   189
 & remap.attributes
patrick@0
   190
selection.division.attributes =
patrick@26
   191
   path.attribute?
patrick@0
   192
patrick@0
   193
composition.division.content =
patrick@20
   194
   composition.head?,
patrick@20
   195
   (composition.division | composition.file)+
patrick@0
   196
selection.division.content =
patrick@20
   197
   selection.head?,
patrick@30
   198
   (selection.division | selection.file | link)+
patrick@0
   199
patrick@0
   200
patrick@0
   201
# =============================================================================
patrick@20
   202
#                                  FILE LEVEL
patrick@0
   203
# =============================================================================
patrick@0
   204
patrick@0
   205
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   206
patrick@30
   207
composition.file = element file { composition.file.attributes }
patrick@2
   208
selection.file = element file { selection.file.attributes, file.content }
patrick@0
   209
patrick@0
   210
composition.file.attributes =
patrick@30
   211
   name.attribute
patrick@30
   212
 & xpath.attribute?
patrick@29
   213
 & xslt.attribute?
patrick@0
   214
selection.file.attributes =
patrick@30
   215
   name.attribute
patrick@30
   216
 & uri.attribute?
patrick@30
   217
name.attribute = attribute name { xsd:anyURI }
patrick@0
   218
patrick@30
   219
file.content = inlines
patrick@30
   220
patrick@30
   221
patrick@0
   222
# =============================================================================
yvon@52
   223
#                                 BLOCK LEVEL
yvon@52
   224
# =============================================================================
yvon@52
   225
yvon@52
   226
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   227
yvon@52
   228
p = element p { p.content }
yvon@52
   229
yvon@52
   230
p.content =
yvon@52
   231
   inlines
yvon@52
   232
yvon@52
   233
yvon@52
   234
# =============================================================================
patrick@20
   235
#                                 INLINE LEVEL
patrick@0
   236
# =============================================================================
patrick@0
   237
patrick@0
   238
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   239
patrick@0
   240
inlines = mixed {
patrick@0
   241
   sup*
patrick@0
   242
 & sub*
patrick@0
   243
}
patrick@0
   244
patrick@0
   245
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   246
patrick@0
   247
sup = element sup { inlines }
patrick@0
   248
patrick@0
   249
sub = element sub { inlines }
patrick@0
   250
patrick@36
   251
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   252
patrick@36
   253
link = element link { link.attributes, link.content }
patrick@36
   254
patrick@36
   255
link.attributes =
patrick@36
   256
   uri.attribute
patrick@36
   257
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   258
patrick@36
   259
link.content = inlines
patrick@36
   260
patrick@0
   261
patrick@0
   262
# =============================================================================
patrick@20
   263
#                               REMAP ATTRIBUTES
patrick@0
   264
# =============================================================================
patrick@0
   265
patrick@0
   266
remap.attributes =
patrick@0
   267
   as.attribute?
patrick@0
   268
 & attributes.attribute?
patrick@0
   269
as.attribute = attribute as { xsd:QName }
patrick@0
   270
attributes.attribute =
patrick@0
   271
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}