RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
sam., 18 juin 2011 15:40:14 +0200
changeset 30 c0f9e813c039
parent 29 0bd36d3b6a5a
child 34 c51d5097d065
permissions -rw-r--r--
Ajustement des sélection
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@18
    77
 & language?
patrick@5
    78
 & author*
patrick@5
    79
 & publisher?
patrick@5
    80
 & source?
patrick@20
    81
division.head.content =
patrick@20
    82
   (title, subtitle?)?
patrick@20
    83
 & language?
patrick@0
    84
patrick@0
    85
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    86
patrick@0
    87
title = element title { title.content }
patrick@18
    88
subtitle = element subtitle { title.content }
patrick@2
    89
patrick@0
    90
title.content = inlines
patrick@0
    91
patrick@18
    92
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ language ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@18
    93
patrick@18
    94
language = element language { language.attributes }
patrick@18
    95
patrick@18
    96
language.attributes = lang.attribute
patrick@18
    97
lang.attribute = attribute xml:lang { xsd:language }
patrick@0
    98
patrick@5
    99
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ author, publisher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   100
patrick@5
   101
# ~~~~~~ author
patrick@5
   102
author = element author { author.content }
patrick@5
   103
patrick@5
   104
author.content =
patrick@5
   105
   firstname?,
patrick@5
   106
   lastname
patrick@5
   107
patrick@5
   108
# ~~~~~~ publisher
patrick@5
   109
publisher = element publisher { publisher.content }
patrick@5
   110
patrick@5
   111
publisher.content = inlines
patrick@5
   112
patrick@5
   113
# ~~~~~~ firstname
patrick@5
   114
firstname = element firstname { firstname.content }
patrick@5
   115
patrick@5
   116
firstname.content = inlines
patrick@5
   117
patrick@5
   118
# ~~~~~~ lastname
patrick@5
   119
lastname = element lastname { lastname.content }
patrick@5
   120
patrick@5
   121
lastname.content = inlines
patrick@5
   122
patrick@0
   123
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   124
patrick@2
   125
# ~~~~~~ source
patrick@0
   126
source = element source {
patrick@0
   127
   source.attributes,
patrick@0
   128
   (  (attribute type { "book" }, source.content.book)
patrick@0
   129
    | (attribute type { "file" }))
patrick@0
   130
}
patrick@0
   131
patrick@0
   132
source.attributes =
patrick@0
   133
   source.id.attribute?
patrick@0
   134
 & remap.attributes
patrick@0
   135
source.id.attribute = attribute id { xsd:NMTOKEN }
patrick@0
   136
patrick@0
   137
source.content.book =
patrick@0
   138
   title?,
patrick@0
   139
   pagenumber?
patrick@0
   140
patrick@2
   141
# ~~~~~~ pagenumber
patrick@0
   142
pagenumber = element pagenumber { pagenumber.attributes }
patrick@2
   143
patrick@0
   144
pagenumber.attributes =
patrick@0
   145
   pagenumber.value.attribute
patrick@0
   146
pagenumber.value.attribute = attribute value { pagenumber.value.enumeration }
patrick@0
   147
pagenumber.value.enumeration = xsd:positiveInteger
patrick@0
   148
patrick@0
   149
patrick@0
   150
# =============================================================================
patrick@20
   151
#                                DIVISION LEVEL
patrick@0
   152
# =============================================================================
patrick@0
   153
patrick@0
   154
composition.division = element division {
patrick@0
   155
   composition.division.attributes,
patrick@0
   156
   composition.division.content
patrick@0
   157
}
patrick@0
   158
selection.division = element division {
patrick@0
   159
   selection.division.attributes,
patrick@0
   160
   selection.division.content
patrick@0
   161
}
patrick@0
   162
patrick@0
   163
composition.division.attributes =
patrick@26
   164
   path.attribute?
patrick@29
   165
 & xpath.attribute?
patrick@23
   166
 & xslt.attribute?
patrick@0
   167
 & remap.attributes
patrick@0
   168
selection.division.attributes =
patrick@26
   169
   path.attribute?
patrick@0
   170
patrick@0
   171
composition.division.content =
patrick@20
   172
   composition.head?,
patrick@20
   173
   (composition.division | composition.file)+
patrick@0
   174
selection.division.content =
patrick@20
   175
   selection.head?,
patrick@30
   176
   (selection.division | selection.file | link)+
patrick@0
   177
patrick@0
   178
patrick@0
   179
# =============================================================================
patrick@20
   180
#                                  FILE LEVEL
patrick@0
   181
# =============================================================================
patrick@0
   182
patrick@0
   183
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   184
patrick@30
   185
composition.file = element file { composition.file.attributes }
patrick@2
   186
selection.file = element file { selection.file.attributes, file.content }
patrick@0
   187
patrick@0
   188
composition.file.attributes =
patrick@30
   189
   name.attribute
patrick@30
   190
 & xpath.attribute?
patrick@29
   191
 & xslt.attribute?
patrick@0
   192
 & remap.attributes
patrick@0
   193
selection.file.attributes =
patrick@30
   194
   name.attribute
patrick@30
   195
 & uri.attribute?
patrick@30
   196
name.attribute = attribute name { xsd:anyURI }
patrick@30
   197
uri.attribute = attribute uri { xsd:anyURI }
patrick@0
   198
patrick@30
   199
file.content = inlines
patrick@30
   200
patrick@30
   201
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@30
   202
patrick@30
   203
link = element link { link.attributes, link.content }
patrick@30
   204
patrick@30
   205
link.attributes =
patrick@30
   206
   uri.attribute
patrick@30
   207
patrick@30
   208
link.content = inlines
patrick@30
   209
patrick@30
   210
patrick@0
   211
# =============================================================================
patrick@20
   212
#                                 INLINE LEVEL
patrick@0
   213
# =============================================================================
patrick@0
   214
patrick@0
   215
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   216
patrick@0
   217
inlines = mixed {
patrick@0
   218
   sup*
patrick@0
   219
 & sub*
patrick@0
   220
}
patrick@0
   221
patrick@0
   222
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   223
patrick@0
   224
sup = element sup { inlines }
patrick@0
   225
patrick@0
   226
sub = element sub { inlines }
patrick@0
   227
patrick@0
   228
patrick@0
   229
# =============================================================================
patrick@20
   230
#                               REMAP ATTRIBUTES
patrick@0
   231
# =============================================================================
patrick@0
   232
patrick@0
   233
remap.attributes =
patrick@0
   234
   as.attribute?
patrick@0
   235
 & attributes.attribute?
patrick@0
   236
as.attribute = attribute as { xsd:QName }
patrick@0
   237
attributes.attribute =
patrick@0
   238
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}