From 44d619ae94d5fc2e4ce0c6bf9ca0b74327175672 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Thu, 26 Feb 2009 04:09:27 +0000 Subject: [PATCH] CSPACE 12: Second iteration of RELAX NG schema for defining and validating an entity, and also - by way of example - a CollectionObject payload. This iteration now defines a set of core fields common to every entity object, a base definition for each field in that object, and two different alternatives - one using infoBlocks, one without - for enclosing sets of related fields. This set of schema now successfully validates a pair of test entity files, also included with this iteration. There are also comments about how we might perform in-line validation using Schematron rules. --- sandbox/aron/schema/CollectionObject.xml | 64 ++++++--- sandbox/aron/schema/CollectionObject2.xml | 95 +++++++++---- .../schema/collectionObject-as-entity.rng | 25 ++++ sandbox/aron/schema/entity.rng | 115 +++++++++------ sandbox/aron/schema/entityCoreFields.rng | 115 +++++++++++++++ sandbox/aron/schema/entityField.rng | 81 ++++++++--- sandbox/aron/schema/entityFieldAttributes.rng | 131 ++++++++++++++++++ 7 files changed, 520 insertions(+), 106 deletions(-) create mode 100644 sandbox/aron/schema/collectionObject-as-entity.rng create mode 100644 sandbox/aron/schema/entityCoreFields.rng create mode 100644 sandbox/aron/schema/entityFieldAttributes.rng diff --git a/sandbox/aron/schema/CollectionObject.xml b/sandbox/aron/schema/CollectionObject.xml index b53a3bb39..9ad68b88b 100644 --- a/sandbox/aron/schema/CollectionObject.xml +++ b/sandbox/aron/schema/CollectionObject.xml @@ -2,29 +2,53 @@ - - CollectionObject - - - - - - - pahma-collectionname-2007-06-09-00055 - - - + + + + + + + + + + + + + + + + + + + + pahma-collectionname-2007-06-09-00055 + + + + Paiute Basket + + + + + + diff --git a/sandbox/aron/schema/CollectionObject2.xml b/sandbox/aron/schema/CollectionObject2.xml index 09b79ce2d..7c3d2e236 100644 --- a/sandbox/aron/schema/CollectionObject2.xml +++ b/sandbox/aron/schema/CollectionObject2.xml @@ -2,33 +2,80 @@ - - CollectionObject - - - - - - - - - pahma-collectionname-2007-06-09-00055 - - - - - + + + + + + + + + + + + + + + + + + + + + + + pahma-collectionname-2007-06-09-00055 + + + + Paiute Basket + + + + + + + + + + Room 231, Shelf 5, Box 18 + + + + + + + + diff --git a/sandbox/aron/schema/collectionObject-as-entity.rng b/sandbox/aron/schema/collectionObject-as-entity.rng new file mode 100644 index 000000000..ed6a35ca6 --- /dev/null +++ b/sandbox/aron/schema/collectionObject-as-entity.rng @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/sandbox/aron/schema/entity.rng b/sandbox/aron/schema/entity.rng index 29ee9632a..1cc36eed1 100644 --- a/sandbox/aron/schema/entity.rng +++ b/sandbox/aron/schema/entity.rng @@ -3,69 +3,86 @@ - - - - - + xmlns="http://relaxng.org/ns/structure/1.0" + datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - + - + + + + - + + + + - + - - - - - - - - - + + + + + + + + + + + + + + + - + + @@ -75,17 +92,31 @@ 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. + written in an XML-based rules language, or can reference in-line + or external JavaScript code (for use within the UI layer of + CollectionSpace), etc. + + One of the possible approaches to specifying validation rules + could be to embed Schematron rules within RELAX NG schema. + As noted in this article, this can be done by inserting + the appropriate XML markup, in the Schematron namespace: + either grouped together below the top-level element or, + throughout the document, within the elements that define + the contexts for the embedded rules: + http://www.xml.com/pub/a/2004/02/11/relaxtron.html + + This page describes the support for processing embedded Schematron + rules in Jing, James Clark's RELAX NG library for Java: + http://www.thaiopensource.com/relaxng/jing-other.html - Also, whether we might wish to have rules that are 'attached' + Also, we might wish to decide whether to offer rules that are 'attached' to individual fields, rather than (or in addition to being) - specified here on a per-entity basis here, is TBD. + specified here on a per-entity basis in a 'validationRules' block. --> - + diff --git a/sandbox/aron/schema/entityCoreFields.rng b/sandbox/aron/schema/entityCoreFields.rng new file mode 100644 index 000000000..7bf5d4771 --- /dev/null +++ b/sandbox/aron/schema/entityCoreFields.rng @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/aron/schema/entityField.rng b/sandbox/aron/schema/entityField.rng index 11a7b2dda..5a151efdd 100644 --- a/sandbox/aron/schema/entityField.rng +++ b/sandbox/aron/schema/entityField.rng @@ -4,11 +4,11 @@ entityField.rng - This schema defines the structure of an individual field (or data element). + A schema defining structure of an individual field (or data element) + in an entity. 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". + a generic business object defined in a separate, related schema, "entity.rng". This schema was created for the CollectionSpace system, http://www.collectionspace.org/ @@ -21,15 +21,9 @@ - - - - - - + xmlns:a="http://relaxng.org/ns/annotation/0.9" + datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + - + - + + + - + + + - + + + - - + + true false - + - + + + + + + + + diff --git a/sandbox/aron/schema/entityFieldAttributes.rng b/sandbox/aron/schema/entityFieldAttributes.rng new file mode 100644 index 000000000..98e298a23 --- /dev/null +++ b/sandbox/aron/schema/entityFieldAttributes.rng @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + false + + + + + + + + + + + + + + + + + + + -- 2.47.3