]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
Initial experiments with creating RELAX NG schema for entities, and validating instan...
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 25 Feb 2009 05:14:25 +0000 (05:14 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 25 Feb 2009 05:14:25 +0000 (05:14 +0000)
sandbox/aron/schema/CollectionObject.xml [new file with mode: 0644]
sandbox/aron/schema/CollectionObject2.xml [new file with mode: 0644]
sandbox/aron/schema/entity.rng [new file with mode: 0644]
sandbox/aron/schema/entityField.rng [new file with mode: 0644]
sandbox/aron/schema/header.txt [new file with mode: 0644]
sandbox/aron/schema/samples/patron.rng [new file with mode: 0644]
sandbox/aron/schema/samples/patron.xml [new file with mode: 0644]

diff --git a/sandbox/aron/schema/CollectionObject.xml b/sandbox/aron/schema/CollectionObject.xml
new file mode 100644 (file)
index 0000000..b53a3bb
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       CollectionObject.xml
+
+       A skeletal instance of an CollectionObject, represented as an XML document.
+       
+       This is created for the CollectionSpace system, http://www.collectionspace.org/
+
+-->
+
+<entity>
+       <entityName>CollectionObject</entityName>
+  <usageNotes>
+    <!-- In-depth notes about usage and meaning go in this field -->
+  </usageNotes>
+  <fields>
+    <field
+      systemName="museumId"
+      displayName="ID"
+       usageNotes="In-depth notes about usage go here"
+       usageHint="Tooltip-type hints go here, such as 'Primary museum ID for this item'"
+      displayed="true"
+      lengthHint="20">
+      <!-- Field contents go here -->
+      pahma-collectionname-2007-06-09-00055
+    </field>
+  </fields>
+</entity>
diff --git a/sandbox/aron/schema/CollectionObject2.xml b/sandbox/aron/schema/CollectionObject2.xml
new file mode 100644 (file)
index 0000000..09b79ce
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       CollectionObject.xml
+
+       A skeletal instance of an CollectionObject, represented as an XML document.
+       
+       This is created for the CollectionSpace system, http://www.collectionspace.org/
+
+-->
+
+<entity>
+       <entityName>CollectionObject</entityName>
+  <usageNotes>
+    <!-- In-depth notes about usage and meaning go in this field -->
+  </usageNotes>
+  <infoBlocks>
+               <infoBlock>
+                       <fields>
+                               <field
+                                       systemName="museumId"
+                                       displayName="ID"
+                                       usageNotes="In-depth notes about usage go here"
+                                       usageHint="Tooltip-type hints go here, such as 'Primary museum ID for this item'"
+                                       displayed="true"
+                                       lengthHint="20">
+                                       <!-- Field contents go here -->
+                                       pahma-collectionname-2007-06-09-00055
+                               </field>
+                       </fields>
+               </infoBlock>
+  </infoBlocks>
+</entity>
diff --git a/sandbox/aron/schema/entity.rng b/sandbox/aron/schema/entity.rng
new file mode 100644 (file)
index 0000000..29ee963
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       entity.rng
+
+       A schema defining the structure of an entity.  An "entity" is a business object;
+       a "noun" within the system.
+       
+       One or more fields of this type are included within an Entity Declaration,
+       which is defined in a separate, related schema file, "Entity.rng".
+       
+       This is a schema definition, using the XML syntax of the RELAX NG schema language,
+       created for the CollectionSpace system, http://www.collectionspace.org/
+       
+       For more information on RELAX NG, please see http://relaxng.org/
+
+-->
+
+<element
+       name="entity" 
+       xmlns="http://relaxng.org/ns/structure/1.0">
+       
+       <!-- Name of the entity -->
+               <element name="entityName">
+                        <text/>
+               </element>
+       
+       <!-- Informational text describing the purpose and usage of this entity -->
+       <optional>
+               <element name="usageNotes">
+                        <text/>
+               </element>
+       </optional>
+    
+  <choice>
+
+  <!--
+       An entity may either contain one or more infoBlocks,
+       each containing one or more fields ...
+  -->  
+       <group>
+                       <element name="infoBlocks">
+                               <element name="infoBlock">
+                                       <element name="fields">
+                                               <oneOrMore>
+                                                       <externalRef href="entityField.rng"/>
+                                               </oneOrMore>
+                                       </element>
+                               </element>
+                       </element>
+               </group>
+
+  <!--
+       ... or may simply contain one or more fields, without any infoBlocks.
+  -->
+               <group>
+                       <element name="fields">
+                               <oneOrMore>
+                                       <externalRef href="entityField.rng"/>
+                               </oneOrMore>
+                       </element>
+               </group>
+
+               <!--
+                       Currently, there isn't an option provided to have some fields
+                       contained within infoBlocks, accompanied by other fields that
+                       are not contained within InfoBlocks.
+               -->
+               
+       </choice>
+       
+
+       <!--
+               An entity may optionally contain validation rules.
+               
+               The content of those rules is TBD.  Conceivably, they can be
+               written in an XML-based rules language, reference in-line or
+               external JavaScript code, etc.
+               
+               Also, whether we might wish to have rules that are 'attached'
+               to individual fields, rather than (or in addition to being)
+               specified here on a per-entity basis here, is TBD.
+       -->
+       <optional>
+               <element name="validationRules">
+                       <oneOrMore>
+                               <element name="validation-rule">
+                                       <!-- Define what goes here -->
+                                       <text/>
+                               </element>
+                       </oneOrMore>
+               </element>
+  </optional>
+
+</element>
diff --git a/sandbox/aron/schema/entityField.rng b/sandbox/aron/schema/entityField.rng
new file mode 100644 (file)
index 0000000..11a7b2d
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       entityField.rng
+
+       This schema defines the structure of an individual field (or data element).
+
+       One or more of these entityFields may be included within an "entity",
+       a generic business object that is defined in a separate, related schema,
+       "entity.rng".
+       
+       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/
+
+-->
+
+<element
+       name="field"
+       xmlns="http://relaxng.org/ns/structure/1.0"
+       datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+       
+       <!-- Datatype -->
+
+       <!--
+               Currently, all entity fields are defined as xs:String datatypes.
+       -->
+       <data type="string" />
+       
+       <!-- Attributes -->
+
+       <!--
+               The name of this field/data element, as used internally by the system.
+               See also "displayName", below.
+       -->
+       <attribute name="systemName">
+               <text/>
+       </attribute>
+       
+       <!--
+               The name of this field/data element, as displayed in the system UI.
+               
+               This name may be customized to meet the needs of a deployed instance,
+               internationalized, etc.
+       -->
+       <attribute name="displayName">
+               <text/>
+       </attribute>
+       
+       <!-- Informational text describing the purpose and usage of this field -->
+       <attribute name="usageNotes">
+                <text/>
+       </attribute>
+
+       <!-- Brief, tooltip-type help text describing the purpose and usage of this field -->
+       <attribute name="usageHint">
+                <text/>
+       </attribute>
+       
+       <!-- A Boolean value indicating whether this field is to be displayed in system UI. -->
+       <attribute name="displayed">
+               <choice>
+                       <value>true</value>
+                       <value>false</value>
+               </choice>
+       </attribute>
+
+       <!--
+               An optional hint regarding the length of this field.
+               
+               This may be used for dynamically laying out fields within a forms-based
+               user interface, or for similar purposes.
+               
+               The meaning of this field is instance-dependent, and may refer
+               to a typical length, or an expected maximum length, for instance.
+               It may also refer to any arbitrary measurement system, such as US-ASCII
+               characters, em units or pixels.
+       -->
+       <optional>
+               <attribute name="lengthHint">
+                       <text/>
+               </attribute>
+       </optional>
+       
+</element>
+
diff --git a/sandbox/aron/schema/header.txt b/sandbox/aron/schema/header.txt
new file mode 100644 (file)
index 0000000..a822211
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       entity.rng
+
+       A schema defining the structure of an entity.  An "entity" is a business object;
+       a "noun" within the system.
+       
+       One or more fields of this type are included within an Entity Declaration,
+       which is defined in a separate, related schema file, "Entity.rng".
+       
+       This is a schema definition, using the XML syntax of the RELAX NG schema language,
+       created for the CollectionSpace system, http://www.collectionspace.org/
+       
+       For more information on RELAX NG, please see http://relaxng.org/
+
+-->
+
+
+
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+       entityField.rng
+
+       This schema defines the structure of an individual field (or data element).
+
+       One or more of these entityFields may be included within an "entity",
+       a generic business object that is defined in a separate, related schema,
+       "entity.rng".
+       
+       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/
+
+-->
+
+
+<grammar
+       xmlns:rng="http://relaxng.org/ns/structure/1.0">
+
+  <start>
+    <ref name="entityField"/>
+  </start>
+
+  <define name="entityField">
+
+
+       </define>
+
+</grammar>
\ No newline at end of file
diff --git a/sandbox/aron/schema/samples/patron.rng b/sandbox/aron/schema/samples/patron.rng
new file mode 100644 (file)
index 0000000..7054cbf
--- /dev/null
@@ -0,0 +1,16 @@
+<element name="patron"
+         xmlns="http://relaxng.org/ns/structure/1.0">
+  <!-- From http://www.ibm.com/developerworks/xml/library/x-matters25.html -->
+  <interleave>
+    <element name="name"><text/></element>
+    <element name="id-num"><text/></element>
+    <zeroOrMore>
+      <element name="book">
+        <choice>
+          <attribute name="isbn"/>
+          <attribute name="title"/>
+        </choice>
+      </element>
+    </zeroOrMore>
+  </interleave>
+</element>
diff --git a/sandbox/aron/schema/samples/patron.xml b/sandbox/aron/schema/samples/patron.xml
new file mode 100644 (file)
index 0000000..9659edd
--- /dev/null
@@ -0,0 +1,7 @@
+<patron>
+       <!-- From http://www.ibm.com/developerworks/xml/library/x-matters25.html -->
+  <book isbn="0-528-84460-X"/>
+  <name>John Doe</name>
+  <id-num>12345678</id-num>
+  <book title="Why RELAX is Clever"/>
+</patron>