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