diff -r 8b0f1432fd11 -r a904cb6b2760 RelaxNG/publimeta.rnc --- /dev/null jeu. janv. 01 00:00:00 1970 +0000 +++ b/RelaxNG/publimeta.rnc sam. nov. 16 09:38:44 2013 +0100 @@ -0,0 +1,258 @@ +# $Id$ + +start = publimeta + + +publimeta = element publimeta { + publimeta.attributes, + publimeta.content +} + +publimeta.attributes = + version.attribute +version.attribute = attribute version { "1.0" } + +publimeta.content = + metadatas + + +# ============================================================================= +# TOP LEVEL +# ============================================================================= + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadatas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +metadatas = element metadatas { metadatas.content } + +metadatas.content = + metadata+ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +metadata = element metadata { metadata.attributes, metadata.content } + +metadata.attributes = + metadata.for.attribute + & lang.attribute? +metadata.for.attribute = attribute for { xsd:NMTOKEN } +lang.attribute = attribute xml:lang { xsd:language } + +metadata.content = + (title, shorttitle?, subtitle*)? + & identifier* + & copyright* + & collection? + & contributors? + & date? + & keywordset? + & subjectset? + & abstract? + & price? + + +# ============================================================================= +# METADATA LEVEL +# ============================================================================= + +# ~~~~~~~~~~~~~~~~~~~~~~~ title, shorttitle, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~ + +title = element title { title.content } +shorttitle = element shorttitle { title.content } +subtitle = element subtitle { title.content } + +title.content = inlines + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~ identifier +identifier = element identifier { + (attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"}) + | (attribute type { "uri" }, for.attribute?, xsd:anyURI) +} + +for.attribute = attribute for { xsd:NCName } + +# ~~~~~~ identifier.ean +identifier.ean = element identifier { + attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"} +} + +# ~~~~~~ identifier.uri +identifier.uri = element identifier { + attribute type { "uri" }, for.attribute?, xsd:anyURI +} + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +copyright = element copyright { copyright.content } + +copyright.content = inlines + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +collection = element collection { collection.content } + +collection.content = inlines + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~ contributors +contributors = element contributors { contributors.content } + +contributors.content = + contributor+ + +# ~~~~~~ contributor +contributor = element contributor { contributor.content } + +contributor.content = + (((firstname, secondname?)?, lastname) | label), + address?, + link?, + role+ + +# ~~~~~~ firstname, secondname, lastname, label +firstname = element firstname { firstname.content } +secondname = element secondname { secondname.content } +lastname = element lastname { lastname.content } +label = element label { label.content } + +firstname.content = inlines +secondname.content = inlines +lastname.content = inlines +label.content = inlines + +# ~~~~~~ address +address = element address { address.content } + +address.content = inlines + +# ~~~~~~ role +role = element role { role.content } + +role.content = "author" | "illustrator" | "publisher" | "packager" + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keyword & subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~ keywordset +keywordset = element keywordset { keywordset.content } + +keywordset.content = keyword+ + +# ~~~~~~ keyword +keyword = element keyword { keyword.content } + +keyword.content = mixed { sup*, sub* } + +# ~~~~~~ subjectset +subjectset = element subjectset { subjectset.content } + +subjectset.content = subject+ + +# ~~~~~~ subject +subject = element subject { subject.content } + +subject.content = mixed { sup*, sub* } + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +abstract = element abstract { abstract.content } + +abstract.content = + p+ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ price ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +price = element price { price.attributes, price.content } + +price.attributes = + currency.attribute +currency.attribute = attribute currency { "EUR" | "USD" } + +price.content = xsd:float + + +# ============================================================================= +# BLOCK LEVEL +# ============================================================================= + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +p = element p { p.content } + +p.content = + inlines + + +# ============================================================================= +# INLINE LEVEL +# ============================================================================= + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +inlines = mixed { + sup* + & sub* + & date* + & name* + & highlight* + & link* +} + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +sup = element sup { inlines } + +sub = element sub { inlines } + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +date = element date { date.attributes, date.content } + +date.attributes = + date.value.attribute +date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear } + +date.content = mixed { sup* } + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +name = element name { name.attributes, name.content } + +name.attributes = + name.of.attribute? +name.of.attribute = attribute of { + "person" | "company" | "book" | "newspaper" | "party" | "painting" + | "movie" } + +name.content = mixed { sup* } + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +highlight = element highlight { highlight.content } + +highlight.content = inlines + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +link = element link { link.attributes, link.content } + +link.attributes = + uri.attribute +uri.attribute = attribute uri { xsd:anyURI } + +link.content = mixed { sup* & sub* & date* & name* & highlight* } + + +# ============================================================================= +# REMAP ATTRIBUTES +# ============================================================================= + +remap.attributes = + as.attribute? + & attributes.attribute? + & transform.attribute? +as.attribute = attribute as { xsd:QName } +attributes.attribute = + attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }} +transform.attribute = attribute transform { xsd:anyURI }