RelaxNG/publimeta.rnc
author Patrick PIERRE
mar., 14 juil. 2015 11:42:14 +0200
changeset 390 dd2d8054885e
parent 384 2f3e64c81871
child 448 9bc794bf36b0
permissions -rw-r--r--
Ajout d'un document
Patrick@260
     1
# $Id$
Patrick@260
     2
Patrick@260
     3
start = publimeta
Patrick@260
     4
Patrick@260
     5
Patrick@260
     6
publimeta = element publimeta {
Patrick@260
     7
   publimeta.attributes,
Patrick@260
     8
   publimeta.content
Patrick@260
     9
}
Patrick@260
    10
Patrick@260
    11
publimeta.attributes =
Patrick@260
    12
   version.attribute
Patrick@260
    13
version.attribute = attribute version { "1.0" }
Patrick@260
    14
Patrick@260
    15
publimeta.content =
Patrick@260
    16
   metadatas
Patrick@260
    17
Patrick@260
    18
Patrick@260
    19
# =============================================================================
Patrick@260
    20
#                                    TOP LEVEL
Patrick@260
    21
# =============================================================================
Patrick@260
    22
Patrick@260
    23
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadatas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
    24
Patrick@260
    25
metadatas = element metadatas { metadatas.content }
Patrick@260
    26
Patrick@260
    27
metadatas.content =
Patrick@260
    28
   metadata+
Patrick@260
    29
Patrick@260
    30
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
    31
Patrick@260
    32
metadata = element metadata { metadata.attributes, metadata.content }
Patrick@260
    33
Patrick@260
    34
metadata.attributes =
Patrick@260
    35
   metadata.for.attribute
Patrick@260
    36
 & lang.attribute?
Patrick@260
    37
metadata.for.attribute = attribute for { xsd:NMTOKEN }
Patrick@260
    38
lang.attribute = attribute xml:lang { xsd:language }
Patrick@355
    39
Patrick@260
    40
metadata.content =
Patrick@384
    41
   (title & shorttitle? & subtitle*)?
Patrick@260
    42
 & identifier*
Patrick@260
    43
 & copyright*
Patrick@260
    44
 & collection?
Patrick@260
    45
 & contributors?
Patrick@260
    46
 & date?
Patrick@260
    47
 & keywordset?
Patrick@260
    48
 & subjectset?
Patrick@260
    49
 & abstract?
Patrick@262
    50
 & price*
Patrick@260
    51
Patrick@260
    52
Patrick@260
    53
# =============================================================================
Patrick@260
    54
#                                  METADATA LEVEL
Patrick@260
    55
# =============================================================================
Patrick@260
    56
Patrick@260
    57
# ~~~~~~~~~~~~~~~~~~~~~~~ title, shorttitle, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
    58
Patrick@260
    59
title = element title { title.content }
Patrick@260
    60
shorttitle = element shorttitle { title.content }
Patrick@260
    61
subtitle = element subtitle { title.content }
Patrick@260
    62
Patrick@260
    63
title.content = inlines
Patrick@260
    64
Patrick@260
    65
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
    66
Patrick@260
    67
# ~~~~~~ identifier
Patrick@260
    68
identifier = element identifier {
Patrick@260
    69
   (attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"})
Patrick@260
    70
 | (attribute type { "uri" }, for.attribute?, xsd:anyURI)
Patrick@260
    71
}
Patrick@260
    72
Patrick@260
    73
for.attribute = attribute for { xsd:NCName }
Patrick@260
    74
Patrick@260
    75
# ~~~~~~ identifier.ean
Patrick@260
    76
identifier.ean = element identifier {
Patrick@260
    77
   attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"}
Patrick@260
    78
}
Patrick@260
    79
Patrick@260
    80
# ~~~~~~ identifier.uri
Patrick@260
    81
identifier.uri = element identifier {
Patrick@260
    82
   attribute type { "uri" }, for.attribute?, xsd:anyURI
Patrick@260
    83
}
Patrick@260
    84
Patrick@260
    85
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
    86
Patrick@260
    87
copyright = element copyright { copyright.content }
Patrick@260
    88
Patrick@260
    89
copyright.content = inlines
Patrick@260
    90
Patrick@260
    91
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
    92
Patrick@260
    93
collection = element collection { collection.content }
Patrick@260
    94
Patrick@260
    95
collection.content = inlines
Patrick@260
    96
Patrick@260
    97
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
    98
Patrick@260
    99
# ~~~~~~ contributors
Patrick@260
   100
contributors = element contributors { contributors.content }
Patrick@260
   101
Patrick@260
   102
contributors.content =
Patrick@260
   103
   contributor+
Patrick@260
   104
Patrick@260
   105
# ~~~~~~ contributor
Patrick@260
   106
contributor = element contributor { contributor.content }
Patrick@260
   107
Patrick@260
   108
contributor.content =
Patrick@263
   109
   identifier.uri?,
Patrick@260
   110
   (((firstname, secondname?)?, lastname) | label),
Patrick@260
   111
   address?,
Patrick@260
   112
   link?,
Patrick@260
   113
   role+
Patrick@260
   114
Patrick@260
   115
# ~~~~~~ firstname, secondname, lastname, label
Patrick@260
   116
firstname = element firstname { firstname.content }
Patrick@260
   117
secondname = element secondname { secondname.content }
Patrick@260
   118
lastname = element lastname { lastname.content }
Patrick@260
   119
label = element label { label.content }
Patrick@260
   120
Patrick@260
   121
firstname.content = inlines
Patrick@260
   122
secondname.content = inlines
Patrick@260
   123
lastname.content = inlines
Patrick@260
   124
label.content = inlines
Patrick@260
   125
Patrick@260
   126
# ~~~~~~ address
Patrick@260
   127
address = element address { address.content }
Patrick@260
   128
Patrick@260
   129
address.content = inlines
Patrick@260
   130
Patrick@260
   131
# ~~~~~~ role
Patrick@260
   132
role = element role { role.content }
Patrick@260
   133
Patrick@260
   134
role.content = "author" | "illustrator" | "publisher" | "packager"
Patrick@260
   135
Patrick@260
   136
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keyword & subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   137
Patrick@260
   138
# ~~~~~~ keywordset
Patrick@260
   139
keywordset = element keywordset { keywordset.content }
Patrick@260
   140
Patrick@260
   141
keywordset.content = keyword+
Patrick@260
   142
Patrick@260
   143
# ~~~~~~ keyword
Patrick@260
   144
keyword = element keyword { keyword.content }
Patrick@260
   145
Patrick@260
   146
keyword.content = mixed { sup*, sub* }
Patrick@260
   147
Patrick@260
   148
# ~~~~~~ subjectset
Patrick@260
   149
subjectset = element subjectset { subjectset.content }
Patrick@260
   150
Patrick@260
   151
subjectset.content = subject+
Patrick@260
   152
Patrick@260
   153
# ~~~~~~ subject
Patrick@260
   154
subject = element subject { subject.content }
Patrick@260
   155
Patrick@260
   156
subject.content = mixed { sup*, sub* }
Patrick@260
   157
Patrick@260
   158
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   159
Patrick@260
   160
abstract = element abstract { abstract.content }
Patrick@260
   161
Patrick@260
   162
abstract.content =
Patrick@260
   163
   p+
Patrick@260
   164
Patrick@260
   165
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ price ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   166
Patrick@260
   167
price = element price { price.attributes, price.content }
Patrick@260
   168
Patrick@260
   169
price.attributes =
Patrick@260
   170
   currency.attribute
Patrick@262
   171
 & excluding_tax.attribute
Patrick@262
   172
 & tax.attribute?
Patrick@265
   173
 & territory.attribute?
Patrick@262
   174
currency.attribute = attribute currency {
Patrick@262
   175
   "EUR" | "USD" | "GBP" | "CAD" | "CHF" | "JPY" | "MXN" | "KRW" | "BRL"
Patrick@262
   176
 | "INR" | "AUD" | "RUB" | "CNY" | "NOK" | "SEK" | "DKK" }
Patrick@262
   177
excluding_tax.attribute = attribute excluding-tax { xsd:boolean }
Patrick@262
   178
tax.attribute = attribute tax { xsd:float }
Patrick@265
   179
territory.attribute = attribute territory { xsd:NMTOKENS }
Patrick@260
   180
Patrick@260
   181
price.content = xsd:float
Patrick@355
   182
Patrick@260
   183
Patrick@260
   184
# =============================================================================
Patrick@260
   185
#                                 BLOCK LEVEL
Patrick@260
   186
# =============================================================================
Patrick@260
   187
Patrick@260
   188
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   189
Patrick@260
   190
p = element p { p.content }
Patrick@260
   191
Patrick@260
   192
p.content =
Patrick@260
   193
   inlines
Patrick@260
   194
Patrick@260
   195
Patrick@260
   196
# =============================================================================
Patrick@260
   197
#                                 INLINE LEVEL
Patrick@260
   198
# =============================================================================
Patrick@260
   199
Patrick@260
   200
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   201
Patrick@260
   202
inlines = mixed {
Patrick@260
   203
   sup*
Patrick@260
   204
 & sub*
Patrick@260
   205
 & date*
Patrick@260
   206
 & name*
Patrick@260
   207
 & highlight*
Patrick@260
   208
 & link*
Patrick@260
   209
}
Patrick@260
   210
Patrick@260
   211
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   212
Patrick@260
   213
sup = element sup { inlines }
Patrick@260
   214
Patrick@260
   215
sub = element sub { inlines }
Patrick@260
   216
Patrick@260
   217
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   218
Patrick@260
   219
date = element date { date.attributes, date.content }
Patrick@260
   220
Patrick@260
   221
date.attributes =
Patrick@260
   222
   date.value.attribute
Patrick@260
   223
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
Patrick@260
   224
Patrick@260
   225
date.content = mixed { sup* }
Patrick@260
   226
Patrick@260
   227
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   228
Patrick@260
   229
name = element name { name.attributes, name.content }
Patrick@260
   230
Patrick@260
   231
name.attributes =
Patrick@260
   232
   name.of.attribute?
Patrick@260
   233
name.of.attribute = attribute of {
Patrick@260
   234
   "person" | "company" | "book" | "newspaper" | "party" | "painting"
Patrick@260
   235
 | "movie" }
Patrick@260
   236
Patrick@260
   237
name.content = mixed { sup* }
Patrick@260
   238
Patrick@260
   239
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   240
Patrick@260
   241
highlight = element highlight { highlight.content }
Patrick@260
   242
Patrick@260
   243
highlight.content = inlines
Patrick@260
   244
Patrick@260
   245
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   246
Patrick@260
   247
link = element link { link.attributes, link.content }
Patrick@260
   248
Patrick@260
   249
link.attributes =
Patrick@260
   250
   uri.attribute
Patrick@260
   251
uri.attribute = attribute uri { xsd:anyURI }
Patrick@260
   252
Patrick@260
   253
link.content = mixed { sup* & sub* & date* & name* & highlight* }
Patrick@260
   254
Patrick@260
   255
Patrick@260
   256
# =============================================================================
Patrick@260
   257
#                               REMAP ATTRIBUTES
Patrick@260
   258
# =============================================================================
Patrick@260
   259
Patrick@260
   260
remap.attributes =
Patrick@260
   261
   as.attribute?
Patrick@260
   262
 & attributes.attribute?
Patrick@260
   263
 & transform.attribute?
Patrick@260
   264
as.attribute = attribute as { xsd:QName }
Patrick@260
   265
attributes.attribute =
Patrick@260
   266
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
Patrick@260
   267
transform.attribute = attribute transform { xsd:anyURI }