Ajout d'un role pour les auteurs
authorPatrick PIERRE <patrick.pierre@prismallia.fr>
lun., 18 juil. 2011 19:10:28 +0200
changeset 33 c70de8fae29d
parent 32 057abb684d35
child 34 c51d5097d065
Ajout d'un role pour les auteurs
RelaxNG/publidoc.rnc
RelaxNG/publidoc.rng
Xml/Documents/torture_test.xml
--- a/RelaxNG/publidoc.rnc	lun. juin 20 18:39:46 2011 +0200
+++ b/RelaxNG/publidoc.rnc	lun. juil. 18 19:10:28 2011 +0200
@@ -105,9 +105,20 @@
 # ~~~~~~ author
 author = element author { author.content }
 
+author.attributes =
+   role.attribute?
+role.attribute = attribute role { "author" | "illustrator" }
+
 author.content =
    firstname?,
-   lastname
+   lastname,
+   role*
+
+role = element role { role.attributes }
+
+role.attributes =
+   role.of.attribute
+role.of.attribute = attribute of { "author" | "illustrator" }
 
 # ~~~~~~ publisher
 publisher = element publisher { publisher.content }
@@ -155,8 +166,7 @@
 
 pagenumber.attributes =
    pagenumber.value.attribute
-pagenumber.value.attribute = attribute value { pagenumber.value.enumeration }
-pagenumber.value.enumeration = xsd:positiveInteger
+pagenumber.value.attribute = attribute value { xsd:positiveInteger }
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -443,8 +453,7 @@
    date.value.attribute
  & date.of.attribute?
 date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
-date.of.attribute = attribute of { date.of.enumeration }
-date.of.enumeration = "birth" | "death"
+date.of.attribute = attribute of { "birth" | "death" }
 
 date.content = mixed { sup* }
 
@@ -454,8 +463,8 @@
 
 name.attributes =
    name.of.attribute?
-name.of.attribute = attribute of { name.of.enumeration }
-name.of.enumeration = "person" | "company" | "book" | "newspaper" | "party"
+name.of.attribute = attribute of
+   { "person" | "company" | "book" | "newspaper" | "party" }
 
 name.content = inlines
 
--- a/RelaxNG/publidoc.rng	lun. juin 20 18:39:46 2011 +0200
+++ b/RelaxNG/publidoc.rng	lun. juil. 18 19:10:28 2011 +0200
@@ -252,11 +252,43 @@
       <ref name="author.content"/>
     </element>
   </define>
+  <define name="author.attributes">
+    <optional>
+      <ref name="role.attribute"/>
+    </optional>
+  </define>
+  <define name="role.attribute">
+    <attribute name="role">
+      <choice>
+        <value>author</value>
+        <value>illustrator</value>
+      </choice>
+    </attribute>
+  </define>
   <define name="author.content">
     <optional>
       <ref name="firstname"/>
     </optional>
     <ref name="lastname"/>
+    <zeroOrMore>
+      <ref name="role"/>
+    </zeroOrMore>
+  </define>
+  <define name="role">
+    <element name="role">
+      <ref name="role.attributes"/>
+    </element>
+  </define>
+  <define name="role.attributes">
+    <ref name="role.of.attribute"/>
+  </define>
+  <define name="role.of.attribute">
+    <attribute name="of">
+      <choice>
+        <value>author</value>
+        <value>illustrator</value>
+      </choice>
+    </attribute>
   </define>
   <!-- ~~~~~~ publisher -->
   <define name="publisher">
@@ -343,12 +375,9 @@
   </define>
   <define name="pagenumber.value.attribute">
     <attribute name="value">
-      <ref name="pagenumber.value.enumeration"/>
+      <data type="positiveInteger"/>
     </attribute>
   </define>
-  <define name="pagenumber.value.enumeration">
-    <data type="positiveInteger"/>
-  </define>
   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
   <!-- ~~~~~~ subjectset -->
   <define name="subjectset">
@@ -971,15 +1000,12 @@
   </define>
   <define name="date.of.attribute">
     <attribute name="of">
-      <ref name="date.of.enumeration"/>
+      <choice>
+        <value>birth</value>
+        <value>death</value>
+      </choice>
     </attribute>
   </define>
-  <define name="date.of.enumeration">
-    <choice>
-      <value>birth</value>
-      <value>death</value>
-    </choice>
-  </define>
   <define name="date.content">
     <mixed>
       <zeroOrMore>
@@ -1001,18 +1027,15 @@
   </define>
   <define name="name.of.attribute">
     <attribute name="of">
-      <ref name="name.of.enumeration"/>
+      <choice>
+        <value>person</value>
+        <value>company</value>
+        <value>book</value>
+        <value>newspaper</value>
+        <value>party</value>
+      </choice>
     </attribute>
   </define>
-  <define name="name.of.enumeration">
-    <choice>
-      <value>person</value>
-      <value>company</value>
-      <value>book</value>
-      <value>newspaper</value>
-      <value>party</value>
-    </choice>
-  </define>
   <define name="name.content">
     <ref name="inlines"/>
   </define>
--- a/Xml/Documents/torture_test.xml	lun. juin 20 18:39:46 2011 +0200
+++ b/Xml/Documents/torture_test.xml	lun. juil. 18 19:10:28 2011 +0200
@@ -8,6 +8,10 @@
       <author>
         <firstname>Patrick</firstname><lastname>PIERRE</lastname>
       </author>
+      <author>
+        <firstname>Tien Haï</firstname><lastname>NGUYEN</lastname>
+        <role of="illustrator"/>
+      </author>
       <publisher>Prismallia</publisher>
       <language xml:lang="fr"/>
       <date value="2001-06"/>