]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
Add schema (RELAX NG, tool-generated XSD) for a list of collection objects.
authorAron Roberts <aron@socrates.berkeley.edu>
Fri, 13 Mar 2009 23:36:18 +0000 (23:36 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Fri, 13 Mar 2009 23:36:18 +0000 (23:36 +0000)
Add an example XML document representing a list of collection objects.
Add a wrapper XSD schema, Hello.xsd, corresponding to Sanjay's document of the same name in the prototype.  This document includes declarations for both individual collection objects and lists of collection objects.
Changed sample documents to use realistic-looking hex strings for CSpace ID values, rather than sequences of (pseudo) random alphanumeric characters.

sandbox/aron/schema/collectionObject-ns.xml
sandbox/aron/schema/collectionObject.xml
sandbox/aron/schema/collectionObjects.rng [new file with mode: 0644]
sandbox/aron/schema/collectionObjects.xml [new file with mode: 0644]
sandbox/aron/schema/collectionObjects.xsd [new file with mode: 0644]
sandbox/aron/schema/hello.xsd [new file with mode: 0644]

index 6a753b08853aa84baf2939970ec310fe9b73b691..4fdd9d4889f213caa2c9fb02a4ad49a8889ba2ff 100644 (file)
@@ -22,7 +22,7 @@
        <serviceMetadata>
        
                <!-- An entirely arbitrary examle -->
-               <collectionSpaceId>org.collectionspace-eR5zB8tX2aE3wN6zG1</collectionSpaceId>
+               <collectionSpaceId>org.collectionspace.797220effa5fa160</collectionSpaceId>
                
        </serviceMetadata>
        
index 071b70855ca30838c5fd37ce0b9d8ac65fc59004..97615c0c03f1b3bf4b0c54869d61652ec2a37cf1 100644 (file)
@@ -20,7 +20,7 @@
        <serviceMetadata>
        
                <!-- An entirely arbitrary examle -->
-               <collectionSpaceId>org.collectionspace-eR5zB8tX2aE3wN6zG1</collectionSpaceId>
+               <collectionSpaceId>org.collectionspace.797220effa5fa160</collectionSpaceId>
                
        </serviceMetadata>
        
diff --git a/sandbox/aron/schema/collectionObjects.rng b/sandbox/aron/schema/collectionObjects.rng
new file mode 100644 (file)
index 0000000..4e84991
--- /dev/null
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       collectionObjects.rng
+       
+       A schema defining the structure of an CollectionObject collection
+       (list of multiple CollectionObjects).
+       
+       This schema includes all of its components, rather than referring
+       to them via 'externalRef' references. As such, it can be used as the
+       basis for generating a W3C XML Schema (XSD) schema, via
+       James Clark's Trang utility (http://http://www.thaiopensource.com/relaxng/trang.html).
+       (Trang version 20081028 can't resolve such references.) 
+       
+       As a convenience, a 'rng-to-xsd.sh' script file, which trivially wraps Trang
+       to generate XSD from a RELAX NG schema, is provided elsewhere in this distribution.
+
+       This schema was created for the CollectionSpace system,
+       http://www.collectionspace.org/
+       
+       It is written in the XML syntax of the RELAX NG schema language,
+       http://relaxng.org/
+       
+  $Author: aron $
+  $Revision: 57 $
+  $Date: 2009-03-05 16:06:06 -0800 (Thu, 05 Mar 2009) $
+
+-->
+
+<element
+       name="collectionObjects"
+       ns="http://collectionspace.org/hello"
+       xmlns="http://relaxng.org/ns/structure/1.0"
+       datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+
+       <!--
+               Sanjay's used a different naming convention in the Person prototype,
+               which would be equivalent here to "collection-object-list-item".
+               
+               We may want to standardize on use of CamelCase or hyphenated lowercase throughout, or
+               else establish a convention for list items which is distinct from that convention.
+       -->
+       
+       <zeroOrMore>
+       
+               <element
+                       name="collectionObjectListItem">
+                       
+                       <element name="collectionSpaceId">
+                               <data type="string" />
+                       </element>
+       
+                       <element name="objectNumber">
+                               <data type="normalizedString">
+                                       <param name="minLength">1</param>
+                               </data>
+                       </element>
+       
+                       <element name="objectName">
+                               <choice>
+                                       <data type="string" />
+                                       <empty />
+                               </choice>
+                       </element>
+       
+                       <element name="uri">
+                               <data type="anyURI" />
+                       </element>
+
+               </element>
+               
+       </zeroOrMore>
+    
+</element>
diff --git a/sandbox/aron/schema/collectionObjects.xml b/sandbox/aron/schema/collectionObjects.xml
new file mode 100644 (file)
index 0000000..abd74ef
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       collectionObjects.xml
+
+       A hypothetical, skeletal instance of an CollectionObjects list payload,
+       represented as an XML document, in a rudimentary root namespace,
+       scoped for the Release 0.1 "Hello World" demo.
+       
+       This is created for the CollectionSpace system, http://www.collectionspace.org/
+
+  $Author: aron $
+  $Revision: 509 $
+  $Date: 2008-10-27 13:55:56 -0700 (Mon, 27 Oct 2008) $
+
+-->
+
+<collectionObjects
+       xmlns="http://collectionspace.org/hello">
+
+       <collectionObjectListItem>
+               <collectionSpaceId>org.collectionspace.797220effa5fa160</collectionSpaceId>
+               <objectNumber>1984.021.0049</objectNumber>
+               <objectName>Radio News, vol. 10, no. 2, August 1928</objectName>
+               <uri>/collectionObjects/1984.021.0049</uri>
+       </collectionObjectListItem>
+
+       <collectionObjectListItem>
+               <collectionSpaceId>org.collectionspace.68ac7dc8f9e743</collectionSpaceId>
+               <objectNumber>1997.005.0437</objectNumber>
+               <objectName>Toy, Gotham City Police Helicopter, 1992</objectName>
+               <uri>/collectionObjects/1997.005.0437</uri>
+       </collectionObjectListItem>
+  
+</collectionObjects>
diff --git a/sandbox/aron/schema/collectionObjects.xsd b/sandbox/aron/schema/collectionObjects.xsd
new file mode 100644 (file)
index 0000000..a0b5bbf
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+elementFormDefault="qualified"
+targetNamespace="http://collectionspace.org/hello"
+xmlns="http://collectionspace.org/hello">
+  <xs:element name="collectionObjects">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element minOccurs="0" maxOccurs="unbounded" ref="collectionObjectListItem"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="collectionObjectListItem">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="collectionSpaceId"/>
+        <xs:element ref="objectNumber"/>
+        <xs:element ref="objectName"/>
+        <xs:element ref="uri"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="collectionSpaceId" type="xs:string"/>
+  <xs:element name="objectNumber">
+    <xs:simpleType>
+      <xs:restriction base="xs:normalizedString">
+        <xs:minLength value="1"/>
+      </xs:restriction>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="objectName">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="uri" type="xs:anyURI"/>
+</xs:schema>
diff --git a/sandbox/aron/schema/hello.xsd b/sandbox/aron/schema/hello.xsd
new file mode 100644 (file)
index 0000000..fd13139
--- /dev/null
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ns="http://collectionspace.org/hello"
+  xmlns="http://collectionspace.org/hello"
+  targetNamespace="http://collectionspace.org/hello"
+  version="0.1"
+>
+
+       <!--
+               Including multiple schemas via an 'include' directive here does work,
+               but results in duplicate declarations for several data elements.
+               
+               As a workaround, both schemas are included in full here.  Several
+               child elements of collectionObject (a single entity) are merely
+               referenced from within collectionObjects (a list).
+       -->
+       
+       <!-- xs:include schemaLocation="collectionObject-ns-no-prefix.xsd"/ -->
+       <!-- xs:include schemaLocation="collectionObjects.xsd"/ -->
+       
+       <!--
+               Sanjay noted:
+               avoid XmlRootElement nightnmare, see
+               http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+       -->
+
+  <xs:element name="collectionObject">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="serviceMetadata"/>
+        <xs:element ref="defaultCollectionObject"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="serviceMetadata">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="collectionSpaceId"/>
+        <xs:element minOccurs="0" ref="created"/>
+        <xs:element minOccurs="0" ref="createdBy"/>
+        <xs:element minOccurs="0" ref="lastModified"/>
+        <xs:element minOccurs="0" ref="lastModifiedBy"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="collectionSpaceId" type="xs:string"/>
+  <xs:element name="created">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:dateTime">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="createdBy">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="lastModified">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:dateTime">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="lastModifiedBy">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="defaultCollectionObject">
+    <xs:complexType>
+      <xs:all>
+        <xs:element ref="objectNumber"/>
+        <xs:element minOccurs="0" ref="otherNumber"/>
+        <xs:element minOccurs="0" ref="briefDescription"/>
+        <xs:element minOccurs="0" ref="comments"/>
+        <xs:element minOccurs="0" ref="distinguishingFeatures"/>
+        <xs:element minOccurs="0" ref="objectName"/>
+        <xs:element minOccurs="0" ref="responsibleDepartment"/>
+        <xs:element minOccurs="0" ref="title"/>
+      </xs:all>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="objectNumber">
+    <xs:simpleType>
+      <xs:restriction base="xs:normalizedString">
+        <xs:minLength value="1"/>
+      </xs:restriction>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="otherNumber">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="briefDescription">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="comments">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="distinguishingFeatures">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="objectName">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="responsibleDepartment">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+  <xs:element name="title">
+    <xs:simpleType>
+      <xs:union memberTypes="xs:string">
+        <xs:simpleType>
+          <xs:restriction base="xs:token">
+            <xs:length value="0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:union>
+    </xs:simpleType>
+  </xs:element>
+
+  <xs:element name="collectionObjects">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element minOccurs="0" maxOccurs="unbounded" ref="collectionObjectListItem"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <!--
+       Note CamelCase here; Sanjay uses the style "collection-object-list-item", and
+       we can and should revert to that if needed.
+  -->
+  <xs:element name="collectionObjectListItem">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="collectionSpaceId"/>
+        <xs:element ref="objectNumber"/>
+        <xs:element ref="objectName"/>
+        <xs:element ref="uri"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="uri" type="xs:anyURI"/>
+
+</xs:schema>
+