]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-12: Added a 'full' collectionObject schema in RELAX NG that includes, rather...
authorAron Roberts <aron@socrates.berkeley.edu>
Fri, 13 Mar 2009 19:59:11 +0000 (19:59 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Fri, 13 Mar 2009 19:59:11 +0000 (19:59 +0000)
NB: the XSD version of the collection object schema included with this commit does not include a CSpace- or Hello World-specific namespace.

sandbox/aron/schema/collectionObject-full.rng [new file with mode: 0644]
sandbox/aron/schema/collectionObject.xsd [new file with mode: 0644]
sandbox/aron/schema/rng-to-xsd.sh [new file with mode: 0644]
sandbox/aron/schema/validate-rng.sh [new file with mode: 0644]

diff --git a/sandbox/aron/schema/collectionObject-full.rng b/sandbox/aron/schema/collectionObject-full.rng
new file mode 100644 (file)
index 0000000..e5fb369
--- /dev/null
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       collectionObject-full.rng
+       
+       A schema defining the structure of an CollectionObject entity.
+       
+       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="collectionObject" 
+       xmlns="http://relaxng.org/ns/structure/1.0">
+
+       
+       <!-- ######################################################################## -->
+       <!-- Service Metadata                                                         -->
+       <!-- ######################################################################## -->
+       
+       <!--
+               Data elements common to every entity object in the CollectionSpace system.
+               
+               This is an quickly conceived-of list for the Release 0.1 "Hello World" demo,
+               and is not intended to be definitive going forward; further definition
+               will be required.
+       -->
+       
+       <element
+               name="serviceMetadata">
+               
+               <!--
+                       A unique CollectionSpace system identifier (ID) for this
+                       entity record.  This is distinguished from any museum-created
+                       or other identifiers that might also be associated with it.
+                               
+                       Note: We may wish to think further about what this element name should be.
+               -->
+               <element name="collectionSpaceId">
+                       <!--
+                               Note: We may potentially wish to specify a regex-type pattern
+                               here for further validating these IDs.
+                       -->
+                       <data type="string" />
+               </element>
+               
+               <!--
+                       All of the data elements after this point are fully optional.
+                       
+                       It's possible we may never want or need to pass these in
+                       routine message payloads, and if so, this merely constitutes
+                       notes/documentation on a few representative types of data that
+                       we might additionally store as system metadata, beyond an identifier.
+                       
+                       It's also possible that we might offer a service to provide this
+                       system metadata for any object, so that, for instance, a client
+                       might be able to retrieve the full modification history for an object.
+                       This *may* even already be envisioned for an already defined or
+                       candidate service ...
+               -->
+               
+                       <!-- ######################### -->
+                       <!-- Creation                  -->
+                       <!-- ######################### -->
+               
+                       <!--
+                               A timestamp for the creation of this entity record, as specified in
+                               http://www.w3.org/TR/xmlschema-2/#dateTime
+                       -->
+                       <optional>
+                               <element name="created">
+                                       <choice>
+                                               <data type="dateTime" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+               
+                       <!-- The system Principal that created this entity record -->
+                       <optional>
+                               <element name="createdBy">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+       
+                       <!-- 
+                               Note: Do we also need 'acting as designate for' information here,
+                               for cases where one system Principal created this entity while
+                               acting as a designate for another Principal?
+                       -->
+               
+                       <!-- ######################### -->
+                       <!-- Last modification         -->
+                       <!-- ######################### -->
+                       
+                       <!--
+                               A timestamp for the last modification of this entity record, as specified in
+                               http://www.w3.org/TR/xmlschema-2/#dateTime
+                       -->
+                       <optional>
+                               <element name="lastModified">
+                                       <choice>
+                                               <data type="dateTime" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+               
+                       <!-- The system Principal that created this entity record -->
+                       <optional>
+                               <element name="lastModifiedBy">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+       
+                       <!-- 
+                               Note: Do we also need 'acting as designate for' information here,
+                               for cases where one system Principal modified this entity while
+                               acting as a designate for another Principal?
+                       -->
+       
+                       <!-- ######################### -->
+                       <!-- Valid from/to             -->
+                       <!-- ######################### -->
+                       
+                       <!--
+                               Patrick mentioned the concept of 'valid to/from' timestamps.
+                               If this applied to entity objects, not to schema, we might
+                               explore that further as another possible type of system metadata. 
+                       -->
+                       
+       </element>
+
+
+       <!-- ######################################################################## -->
+       <!-- Default CollectionObject                                                 -->
+       <!-- ######################################################################## -->
+
+       <!-- The default CollectionSpace schema for an entity object (extremely simplified). -->
+
+       <element
+               name="defaultCollectionObject" 
+               xmlns="http://relaxng.org/ns/structure/1.0"
+               datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+               
+               <!--
+                       The following data elements are taken from the Basic section,
+                       Object ID Information sub-section, of the Object Data Entry wireframe
+                       
+                       See:
+                       
+                       http://wiki.collectionspace.org/display/collectionspace/Wireframes+-+Object+Data+Entry
+                       and
+                       http://wiki.collectionspace.org/display/collectionspace/Hello+World+(Release+0.1)+Functionality+Requirements
+                       
+               -->
+       
+               <!-- Allows child elements to appear in any order -->
+               <interleave>
+               
+                       <element name="objectNumber">
+                               <!--
+                                       This declaration specifies that the value of this element must never be empty (blank).
+                                       If that's not accurate, it should be redefined, perhaps to match other elements below.
+                                       
+                                       Note: In a site- or instance-specific declaration - not in the default
+                                       definition here - we might wish to specify a regex-type pattern here for
+                                       further constraining valid object numbers.
+                               -->
+                               <data type="normalizedString">
+                                       <param name="minLength">1</param>
+                               </data>
+                       </element>
+       
+                       <optional>
+                               <element name="otherNumber">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+                       
+                       <optional>
+                               <element name="briefDescription">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+                       
+                       <optional>
+                               <element name="comments">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+                       
+                       <optional>
+                               <element name="distinguishingFeatures">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+                       
+                       <optional>
+                               <element name="objectName">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+                       
+                       <optional>
+                               <element name="responsibleDepartment">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+                       
+                       <optional>
+                               <element name="title">
+                                       <choice>
+                                               <data type="string" />
+                                               <empty />
+                                       </choice>
+                               </element>
+                       </optional>
+       
+               </interleave>
+                               
+       </element>      
+
+       <!-- A domain- or community-provided schema, if available, would go here -->
+       
+       <!-- An site- or instance-provided schema, if available, would go here. -->
+       
+    
+</element>
diff --git a/sandbox/aron/schema/collectionObject.xsd b/sandbox/aron/schema/collectionObject.xsd
new file mode 100644 (file)
index 0000000..1d8bbe8
--- /dev/null
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+  <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:schema>
diff --git a/sandbox/aron/schema/rng-to-xsd.sh b/sandbox/aron/schema/rng-to-xsd.sh
new file mode 100644 (file)
index 0000000..7ed9aba
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# rng-to-xsd.sh
+# 
+# Simple bash shell script to generate a W3C XML Schema (XSD) document
+# from a RELAX NG schema document.
+#
+# Requires two arguments:
+# - Filename of the RELAX NG schema document.
+#   (or the full path to this document, if it is not in the current directory)
+# - Filename of the new XML instance document to be created.
+#   (or the full path to this document, if it is not in the current directory)
+#
+# $Author: aron $
+# $Revision: 57 $
+# $Date: 2009-03-05 16:06:06 -0800 (Thu, 05 Mar 2009) $
+
+java -jar tools/trang.jar -I rng -O xsd $1 $2
\ No newline at end of file
diff --git a/sandbox/aron/schema/validate-rng.sh b/sandbox/aron/schema/validate-rng.sh
new file mode 100644 (file)
index 0000000..5b0e3a4
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Simple bash shell script to validate an XML instance document
+# against a RELAX NG schema.
+#
+# Requires two arguments:
+# - Filename of the RELAX NG schema document.
+#   (or the full path to this document, if it is not in the current directory)
+# - Filename of the XML instance document
+#   (or the full path to this document, if it is not in the current directory)
+#
+# $Author: aron $
+# $Revision: 57 $
+# $Date: 2009-03-05 16:06:06 -0800 (Thu, 05 Mar 2009) $
+
+java -jar tools/jing.jar $1 $2
\ No newline at end of file