RelaxNG/publimeta.rnc
author Patrick PIERRE
dim., 17 nov. 2013 15:19:01 +0100
changeset 262 2906cd61506b
parent 260 a904cb6b2760
child 263 b6ac75b447ae
permissions -rw-r--r--
Ajout de la gestion des taxes
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@260
    39
   
Patrick@260
    40
metadata.content =
Patrick@260
    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@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@262
   172
currency.attribute = attribute currency {
Patrick@262
   173
   "EUR" | "USD" | "GBP" | "CAD" | "CHF" | "JPY" | "MXN" | "KRW" | "BRL"
Patrick@262
   174
 | "INR" | "AUD" | "RUB" | "CNY" | "NOK" | "SEK" | "DKK" }
Patrick@262
   175
excluding_tax.attribute = attribute excluding-tax { xsd:boolean }
Patrick@262
   176
tax.attribute = attribute tax { xsd:float }
Patrick@260
   177
Patrick@260
   178
price.content = xsd:float
Patrick@260
   179
   
Patrick@260
   180
Patrick@260
   181
# =============================================================================
Patrick@260
   182
#                                 BLOCK LEVEL
Patrick@260
   183
# =============================================================================
Patrick@260
   184
Patrick@260
   185
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   186
Patrick@260
   187
p = element p { p.content }
Patrick@260
   188
Patrick@260
   189
p.content =
Patrick@260
   190
   inlines
Patrick@260
   191
Patrick@260
   192
Patrick@260
   193
# =============================================================================
Patrick@260
   194
#                                 INLINE LEVEL
Patrick@260
   195
# =============================================================================
Patrick@260
   196
Patrick@260
   197
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   198
Patrick@260
   199
inlines = mixed {
Patrick@260
   200
   sup*
Patrick@260
   201
 & sub*
Patrick@260
   202
 & date*
Patrick@260
   203
 & name*
Patrick@260
   204
 & highlight*
Patrick@260
   205
 & link*
Patrick@260
   206
}
Patrick@260
   207
Patrick@260
   208
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   209
Patrick@260
   210
sup = element sup { inlines }
Patrick@260
   211
Patrick@260
   212
sub = element sub { inlines }
Patrick@260
   213
Patrick@260
   214
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   215
Patrick@260
   216
date = element date { date.attributes, date.content }
Patrick@260
   217
Patrick@260
   218
date.attributes =
Patrick@260
   219
   date.value.attribute
Patrick@260
   220
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
Patrick@260
   221
Patrick@260
   222
date.content = mixed { sup* }
Patrick@260
   223
Patrick@260
   224
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   225
Patrick@260
   226
name = element name { name.attributes, name.content }
Patrick@260
   227
Patrick@260
   228
name.attributes =
Patrick@260
   229
   name.of.attribute?
Patrick@260
   230
name.of.attribute = attribute of {
Patrick@260
   231
   "person" | "company" | "book" | "newspaper" | "party" | "painting"
Patrick@260
   232
 | "movie" }
Patrick@260
   233
Patrick@260
   234
name.content = mixed { sup* }
Patrick@260
   235
Patrick@260
   236
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   237
Patrick@260
   238
highlight = element highlight { highlight.content }
Patrick@260
   239
Patrick@260
   240
highlight.content = inlines
Patrick@260
   241
Patrick@260
   242
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   243
Patrick@260
   244
link = element link { link.attributes, link.content }
Patrick@260
   245
Patrick@260
   246
link.attributes =
Patrick@260
   247
   uri.attribute
Patrick@260
   248
uri.attribute = attribute uri { xsd:anyURI }
Patrick@260
   249
Patrick@260
   250
link.content = mixed { sup* & sub* & date* & name* & highlight* }
Patrick@260
   251
Patrick@260
   252
Patrick@260
   253
# =============================================================================
Patrick@260
   254
#                               REMAP ATTRIBUTES
Patrick@260
   255
# =============================================================================
Patrick@260
   256
Patrick@260
   257
remap.attributes =
Patrick@260
   258
   as.attribute?
Patrick@260
   259
 & attributes.attribute?
Patrick@260
   260
 & transform.attribute?
Patrick@260
   261
as.attribute = attribute as { xsd:QName }
Patrick@260
   262
attributes.attribute =
Patrick@260
   263
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
Patrick@260
   264
transform.attribute = attribute transform { xsd:anyURI }