RelaxNG/publimeta.rnc
author Patrick PIERRE
sam., 16 nov. 2013 09:38:44 +0100
changeset 260 a904cb6b2760
child 262 2906cd61506b
permissions -rw-r--r--
Ajout du Relax NG de métadonnées
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@260
    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@260
   170
currency.attribute = attribute currency { "EUR" | "USD" }
Patrick@260
   171
Patrick@260
   172
price.content = xsd:float
Patrick@260
   173
   
Patrick@260
   174
Patrick@260
   175
# =============================================================================
Patrick@260
   176
#                                 BLOCK LEVEL
Patrick@260
   177
# =============================================================================
Patrick@260
   178
Patrick@260
   179
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   180
Patrick@260
   181
p = element p { p.content }
Patrick@260
   182
Patrick@260
   183
p.content =
Patrick@260
   184
   inlines
Patrick@260
   185
Patrick@260
   186
Patrick@260
   187
# =============================================================================
Patrick@260
   188
#                                 INLINE LEVEL
Patrick@260
   189
# =============================================================================
Patrick@260
   190
Patrick@260
   191
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   192
Patrick@260
   193
inlines = mixed {
Patrick@260
   194
   sup*
Patrick@260
   195
 & sub*
Patrick@260
   196
 & date*
Patrick@260
   197
 & name*
Patrick@260
   198
 & highlight*
Patrick@260
   199
 & link*
Patrick@260
   200
}
Patrick@260
   201
Patrick@260
   202
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   203
Patrick@260
   204
sup = element sup { inlines }
Patrick@260
   205
Patrick@260
   206
sub = element sub { inlines }
Patrick@260
   207
Patrick@260
   208
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   209
Patrick@260
   210
date = element date { date.attributes, date.content }
Patrick@260
   211
Patrick@260
   212
date.attributes =
Patrick@260
   213
   date.value.attribute
Patrick@260
   214
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
Patrick@260
   215
Patrick@260
   216
date.content = mixed { sup* }
Patrick@260
   217
Patrick@260
   218
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   219
Patrick@260
   220
name = element name { name.attributes, name.content }
Patrick@260
   221
Patrick@260
   222
name.attributes =
Patrick@260
   223
   name.of.attribute?
Patrick@260
   224
name.of.attribute = attribute of {
Patrick@260
   225
   "person" | "company" | "book" | "newspaper" | "party" | "painting"
Patrick@260
   226
 | "movie" }
Patrick@260
   227
Patrick@260
   228
name.content = mixed { sup* }
Patrick@260
   229
Patrick@260
   230
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   231
Patrick@260
   232
highlight = element highlight { highlight.content }
Patrick@260
   233
Patrick@260
   234
highlight.content = inlines
Patrick@260
   235
Patrick@260
   236
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@260
   237
Patrick@260
   238
link = element link { link.attributes, link.content }
Patrick@260
   239
Patrick@260
   240
link.attributes =
Patrick@260
   241
   uri.attribute
Patrick@260
   242
uri.attribute = attribute uri { xsd:anyURI }
Patrick@260
   243
Patrick@260
   244
link.content = mixed { sup* & sub* & date* & name* & highlight* }
Patrick@260
   245
Patrick@260
   246
Patrick@260
   247
# =============================================================================
Patrick@260
   248
#                               REMAP ATTRIBUTES
Patrick@260
   249
# =============================================================================
Patrick@260
   250
Patrick@260
   251
remap.attributes =
Patrick@260
   252
   as.attribute?
Patrick@260
   253
 & attributes.attribute?
Patrick@260
   254
 & transform.attribute?
Patrick@260
   255
as.attribute = attribute as { xsd:QName }
Patrick@260
   256
attributes.attribute =
Patrick@260
   257
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
Patrick@260
   258
transform.attribute = attribute transform { xsd:anyURI }