Commit f99cc5cb authored by AS's avatar AS
Browse files

New schema, including build tools for ant.

parent b6ec8466
<?xml version="1.0" encoding="UTF-8" ?>
<!-- - HGI Device Abstraction Layer - - - - - - - - - - - - - - - - - - - - -->
<!-- -->
<!-- Extends the standard build with targets for: -->
<!-- - generate XML schema the from Relax NG (xml) description -->
<!-- - validate DAL documents against the XML Schema -->
<!-- - generate HTML documentation from DAL documents -->
<project name="importing" basedir="." default="schemas">
<import file="../../etc/common.xml"/>
<!-- Read the namespace declarations from a file (to get linebreaks) - - - -->
<loadfile property="schema.xmlns" srcFile="${basedir}/etc/schema.xmlns"/>
<!-- The RNG file the XML and RNC schemas are generaed from - - - - - - - -->
<property name="" value="domain"/>
<property name="schema.rng" value="${path.src}/${}.rng"/>
<!-- HTML - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- -->
<!-- Generate HTML documentation from domain definitions in the test -->
<!-- directory. The module classes included via the extends tagged are -->
<!-- included in the documentation - so an xinclude capable XSL engine is -->
<!-- needed. -->
<!-- This needs Ant version 1.8+ and it must be augmented with an current -->
<!-- version of Xerces. Download the binray distribution and place the put -->
<!-- xml-apis.jar and xercesImpl.jar in the Ant lib directory. -->
<target name="html">
<xslt basedir="${basedir}/test" destdir="${basedir}/html"
<param name="destdir" expression="${basedir}/html"/>
<!-- Schemas - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- -->
<!-- The schema is specified using Relax NG (xml) and trang is used to -->
<!-- generate the XML schema. The schema is also generated in Relay NG -->
<!-- compact syntax, which is used by some validating editors (e.g. emacs) -->
<!-- The resulting schemas need some additional patching before thy are -->
<!-- usable -->
<target name="schemas">
<java jar="${basedir}/lib/trang.jar" fork="true">
<arg value="${schema.rng}"/>
<arg value="${basedir}/etc/${}.rnc"/>
<!-- So that the editor does not complain about include directives, the -->
<!-- resulting schema is included in another schema, which includes the -->
<!-- necessary element definitions. To be able to do this the -->
<!-- definition for Imports must be deleted from this generated schema. -->
<replace file="${basedir}/etc/${}.rnc"
token="Imports = element Imports { Domain* }?" value=""/>
<java jar="${basedir}/lib/trang.jar" fork="true">
<arg value="${schema.rng}"/>
<arg value="${path.src}/${}.xsd"/>
<!-- Can't validate against the generated schema unless we add the -->
<!-- target and default namespaces ... -->
<replace file='${path.src}/domain.xsd'
<!-- In addition the xml:base tag, which is added automatically when -->
<!-- including a document, must also be permitted by out schema. -->
<!-- The schema generated from RNG is almost correct schema ... but -->
<!-- the schemaLocation is wrong. -->
<replace file='${path.src}/domain.xsd'
token="xml.xsd" value=""/>
<!-- Validate - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- -->
<!-- Check the Device Description conforms to the Device Abstraction -->
<!-- Schema. Note that we need to activate support for XML includes -->
<target name="validate" depends="">
<schemavalidate warn="true">
<fileset dir="${basedir}/test" includes="*.xml"/>
<attribute name="" value="true"/>
<schema namespace=""
file="${path.src}/domain.xsd" />
<schema namespace=""
file="${basedir}/etc/XInclude.xsd" />
<schema namespace=""
file="${basedir}/etc/XMLSchema.xsd" />
<xs:schema xmlns:xs=""
Not normative, but may be useful.
See the REC for definitive
information about this namespace.
<xs:element name="include" type="xi:includeType" />
<xs:complexType name="includeType" mixed="true">
<xs:choice minOccurs='0' maxOccurs='unbounded' >
<xs:element ref='xi:fallback' />
<xs:any namespace='##other' processContents='lax' />
<xs:any namespace='##local' processContents='lax' />
<xs:attribute name="href" use="optional" type="xs:anyURI"/>
<xs:attribute name="parse" use="optional" default="xml"
type="xi:parseType" />
<xs:attribute name="xpointer" use="optional" type="xs:string"/>
<xs:attribute name="encoding" use="optional" type="xs:string"/>
<xs:attribute name="accept" use="optional" type="xs:string"/>
<xs:attribute name="accept-language" use="optional" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
<xs:simpleType name="parseType">
<xs:restriction base="xs:token">
<xs:enumeration value="xml"/>
<xs:enumeration value="text"/>
<xs:element name="fallback" type="xi:fallbackType" />
<xs:complexType name="fallbackType" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xi:include"/>
<xs:any namespace="##other" processContents="lax"/>
<xs:any namespace="##local" processContents="lax"/>
<xs:anyAttribute namespace="##other" processContents="lax" />
<?xml version='1.0'?>
<!-- XML Schema schema for XML Schemas: Part 2: Datatypes -->
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" [
<!ENTITY % s ''>
<!ENTITY % p ''>
<schema xmlns="" targetNamespace=""
version="$Id: XMLSchema-datatypes.xsd,v 1.5 2001/03/16 20:53:32 ht Exp $">
<documentation>Note this schema is NOT a normative schema - -
It contains types derived from all the builtin simple type definitions
with the same local name but in a distinct namespace, for use
by applications which do no wish to import the full XMLSchema
schema. Since derivation is not symmetric, unexpected results may
follow from mixing references to these definitions with references
to the definitions in the XMLSchema namespace. For example,
although dt:positiveInteger is derived from xs:integer, the converse
does not hold.</documentation>
<simpleType name="string">
<restriction base="string"/>
<simpleType name="boolean">
<restriction base="boolean"/>
<simpleType name="float">
<restriction base="float"/>
<simpleType name="double">
<restriction base="double"/>
<simpleType name="decimal">
<restriction base="decimal"/>
<simpleType name="dateTime">
<restriction base="dateTime"/>
<simpleType name="duration">
<restriction base="duration"/>
<simpleType name="hexBinary">
<restriction base="hexBinary"/>
<simpleType name="base64Binary">
<restriction base="base64Binary"/>
<simpleType name="anyURI">
<restriction base="anyURI"/>
<simpleType name="ID">
<restriction base="ID"/>
<simpleType name="IDREF">
<restriction base="IDREF"/>
<simpleType name="ENTITY">
<restriction base="ENTITY"/>
<simpleType name="NOTATION">
<restriction base="NOTATION"/>
<simpleType name="normalizedString">
<restriction base="normalizedString"/>
<simpleType name="token">
<restriction base="token"/>
<simpleType name="language">
<restriction base="language"/>
<simpleType name="IDREFS">
<restriction base="IDREFS"/>
<simpleType name="ENTITIES">
<restriction base="ENTITIES"/>
<simpleType name="NMTOKEN">
<restriction base="NMTOKEN"/>
<simpleType name="NMTOKENS">
<restriction base="NMTOKENS"/>
<simpleType name="Name">
<restriction base="Name"/>
<simpleType name="QName">
<restriction base="QName"/>
<simpleType name="NCName">
<restriction base="NCName"/>
<simpleType name="integer">
<restriction base="integer"/>
<simpleType name="nonNegativeInteger">
<restriction base="nonNegativeInteger"/>
<simpleType name="positiveInteger">
<restriction base="positiveInteger"/>
<simpleType name="nonPositiveInteger">
<restriction base="nonPositiveInteger"/>
<simpleType name="negativeInteger">
<restriction base="negativeInteger"/>
<simpleType name="byte">
<restriction base="byte"/>
<simpleType name="int">
<restriction base="int"/>
<simpleType name="long">
<restriction base="long"/>
<simpleType name="short">
<restriction base="short"/>
<simpleType name="unsignedByte">
<restriction base="unsignedByte"/>
<simpleType name="unsignedInt">
<restriction base="unsignedInt"/>
<simpleType name="unsignedLong">
<restriction base="unsignedLong"/>
<simpleType name="unsignedShort">
<restriction base="unsignedShort"/>
<simpleType name="date">
<restriction base="date"/>
<simpleType name="time">
<restriction base="time"/>
<simpleType name="gYearMonth">
<restriction base="gYearMonth"/>
<simpleType name="gYear">
<restriction base="gYear"/>
<simpleType name="gMonthDay">
<restriction base="gMonthDay"/>
<simpleType name="gDay">
<restriction base="gDay"/>
<simpleType name="gMonth">
<restriction base="gMonth"/>
<!-- DTD for XML Schemas: Part 1: Structures
Public Identifier: "-//W3C//DTD XMLSCHEMA 200102//EN"
Official Location: -->
<!-- $Id: XMLSchema.dtd,v 1.31 2001/10/24 15:50:16 ht Exp $ -->
<!-- Note this DTD is NOT normative, or even definitive. --> <!--d-->
<!-- prose copy in the structures REC is the definitive version --> <!--d-->
<!-- (which shouldn't differ from this one except for this --> <!--d-->
<!-- comment and entity expansions, but just in case) --> <!--d-->
<!-- With the exception of cases with multiple namespace
prefixes for the XML Schema namespace, any XML document which is
not valid per this DTD given redefinitions in its internal subset of the
'p' and 's' parameter entities below appropriate to its namespace
declaration of the XML Schema namespace is almost certainly not
a valid schema. -->
<!-- The simpleType element and its constituent parts
are defined in XML Schema: Part 2: Datatypes -->
<!ENTITY % xs-datatypes PUBLIC 'datatypes' 'datatypes.dtd' >
<!ENTITY % p 'xs:'> <!-- can be overriden in the internal subset of a
schema document to establish a different
namespace prefix -->
<!ENTITY % s ':xs'> <!-- if %p is defined (e.g. as foo:) then you must
also define %s as the suffix for the appropriate
namespace declaration (e.g. :foo) -->
<!ENTITY % nds 'xmlns%s;'>
<!-- Define all the element names, with optional prefix -->
<!ENTITY % schema "%p;schema">
<!ENTITY % complexType "%p;complexType">
<!ENTITY % complexContent "%p;complexContent">
<!ENTITY % simpleContent "%p;simpleContent">
<!ENTITY % extension "%p;extension">
<!ENTITY % element "%p;element">
<!ENTITY % unique "%p;unique">
<!ENTITY % key "%p;key">
<!ENTITY % keyref "%p;keyref">
<!ENTITY % selector "%p;selector">
<!ENTITY % field "%p;field">
<!ENTITY % group "%p;group">
<!ENTITY % all "%p;all">
<!ENTITY % choice "%p;choice">
<!ENTITY % sequence "%p;sequence">
<!ENTITY % any "%p;any">
<!ENTITY % anyAttribute "%p;anyAttribute">
<!ENTITY % attribute "%p;attribute">
<!ENTITY % attributeGroup "%p;attributeGroup">
<!ENTITY % include "%p;include">
<!ENTITY % import "%p;import">
<!ENTITY % redefine "%p;redefine">
<!ENTITY % notation "%p;notation">
<!-- annotation elements -->
<!ENTITY % annotation "%p;annotation">
<!ENTITY % appinfo "%p;appinfo">
<!ENTITY % documentation "%p;documentation">
<!-- Customisation entities for the ATTLIST of each element type.
Define one of these if your schema takes advantage of the
anyAttribute='##other' in the schema for schemas -->
<!ENTITY % schemaAttrs ''>
<!ENTITY % complexTypeAttrs ''>
<!ENTITY % complexContentAttrs ''>
<!ENTITY % simpleContentAttrs ''>
<!ENTITY % extensionAttrs ''>
<!ENTITY % elementAttrs ''>
<!ENTITY % groupAttrs ''>
<!ENTITY % allAttrs ''>
<!ENTITY % choiceAttrs ''>
<!ENTITY % sequenceAttrs ''>
<!ENTITY % anyAttrs ''>
<!ENTITY % anyAttributeAttrs ''>
<!ENTITY % attributeAttrs ''>
<!ENTITY % attributeGroupAttrs ''>
<!ENTITY % uniqueAttrs ''>
<!ENTITY % keyAttrs ''>
<!ENTITY % keyrefAttrs ''>
<!ENTITY % selectorAttrs ''>
<!ENTITY % fieldAttrs ''>
<!ENTITY % includeAttrs ''>
<!ENTITY % importAttrs ''>
<!ENTITY % redefineAttrs ''>
<!ENTITY % notationAttrs ''>
<!ENTITY % annotationAttrs ''>
<!ENTITY % appinfoAttrs ''>
<!ENTITY % documentationAttrs ''>
<!ENTITY % complexDerivationSet "CDATA">
<!-- #all or space-separated list drawn from derivationChoice -->
<!ENTITY % blockSet "CDATA">
<!-- #all or space-separated list drawn from
derivationChoice + 'substitution' -->
<!ENTITY % mgs '%all; | %choice; | %sequence;'>
<!ENTITY % cs '%choice; | %sequence;'>
<!ENTITY % formValues '(qualified|unqualified)'>
<!ENTITY % attrDecls '((%attribute;| %attributeGroup;)*,(%anyAttribute;)?)'>
<!ENTITY % particleAndAttrs '((%mgs; | %group;)?, %attrDecls;)'>
<!-- This is used in part2 -->
<!ENTITY % restriction1 '((%mgs; | %group;)?)'>
<!-- the duplication below is to produce an unambiguous content model
which allows annotation everywhere -->
<!ELEMENT %schema; ((%include; | %import; | %redefine; | %annotation;)*,
((%simpleType; | %complexType;
| %element; | %attribute;
| %attributeGroup; | %group;
| %notation; ),
(%annotation;)*)* )>
<!ATTLIST %schema;
targetNamespace %URIref; #IMPLIED
%nds; %URIref; #FIXED ''
finalDefault %complexDerivationSet; ''
blockDefault %blockSet; ''
elementFormDefault %formValues; 'unqualified'
attributeFormDefault %formValues; 'unqualified'
<!-- Note the xmlns declaration is NOT in the Schema for Schemas,
because at the Infoset level where schemas operate,
xmlns(:prefix) is NOT an attribute! -->
<!-- The declaration of xmlns is a convenience for schema authors -->
<!-- The id attribute here and below is for use in external references
from non-schemas using simple fragment identifiers.
It is NOT used for schema-to-schema reference, internal or
external. -->
<!-- a type is a named content type specification which allows attribute
<!-- -->
<!ELEMENT %complexType; ((%annotation;)?,
<!ATTLIST %complexType;
name %NCName; #IMPLIED
abstract %boolean; #IMPLIED
final %complexDerivationSet; #IMPLIED
block %complexDerivationSet; #IMPLIED
mixed (true|false) 'false'
<!-- particleAndAttrs is shorthand for a root type -->
<!-- mixed is disallowed if simpleContent, overriden if complexContent
has one too. -->
<!-- If anyAttribute appears in one or more referenced attributeGroups
and/or explicitly, the intersection of the permissions is used -->
<!ELEMENT %complexContent; ((%annotation;)?, (%restriction;|%extension;))>
<!ATTLIST %complexContent;
mixed (true|false) #IMPLIED
<!-- restriction should use the branch defined above, not the simple
one from part2; extension should use the full model -->
<!ELEMENT %simpleContent; ((%annotation;)?, (%restriction;|%extension;))>
<!ATTLIST %simpleContent;
<!-- restriction should use the simple branch from part2, not the
one defined above; extension should have no particle -->
<!ELEMENT %extension; ((%annotation;)?, (%particleAndAttrs;))>
<!ATTLIST %extension;
base %QName; #REQUIRED
<!-- an element is declared by either:
a name and a type (either nested or referenced via the type attribute)
or a ref to an existing element declaration -->
<!ELEMENT %element; ((%annotation;)?, (%complexType;| %simpleType;)?,
(%unique; | %key; | %keyref;)*)>
<!-- simpleType or complexType only if no type|ref attribute -->
<!-- ref not allowed at top level -->
<!ATTLIST %element;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
type %QName; #IMPLIED
minOccurs %nonNegativeInteger; #IMPLIED
nillable %boolean; #IMPLIED
substitutionGroup %QName; #IMPLIED
abstract %boolean; #IMPLIED
final %complexDerivationSet; #IMPLIED
block %blockSet; #IMPLIED
form %formValues; #IMPLIED
<!-- type and ref are mutually exclusive.
name and ref are mutually exclusive, one is required -->
<!-- In the absence of type AND ref, type defaults to type of
substitutionGroup, if any, else the ur-type, i.e. unconstrained -->
<!-- default and fixed are mutually exclusive -->
<!ELEMENT %group; ((%annotation;)?,(%mgs;)?)>
<!ATTLIST %group;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
minOccurs %nonNegativeInteger; #IMPLIED
<!ELEMENT %all; ((%annotation;)?, (%element;)*)>
<!ATTLIST %all;
minOccurs (1) #IMPLIED
maxOccurs (1) #IMPLIED
<!ELEMENT %choice; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
<!ATTLIST %choice;
minOccurs %nonNegativeInteger; #IMPLIED
<!ELEMENT %sequence; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
<!ATTLIST %sequence;
minOccurs %nonNegativeInteger; #IMPLIED
<!-- an anonymous grouping in a model, or
a top-level named group definition, or a reference to same -->
<!-- Note that if order is 'all', group is not allowed inside.
If order is 'all' THIS group must be alone (or referenced alone) at
the top level of a content model -->
<!-- If order is 'all', minOccurs==maxOccurs==1 on element/any inside -->
<!-- Should allow minOccurs=0 inside order='all' . . . -->
<!ELEMENT %any; (%annotation;)?>
<!ATTLIST %any;
namespace CDATA '##any'
processContents (skip|lax|strict) 'strict'
minOccurs %nonNegativeInteger; '1'
maxOccurs CDATA '1'
<!-- namespace is interpreted as follows:
##any - - any non-conflicting WFXML at all
##other - - any non-conflicting WFXML from namespace other
than targetNamespace
##local - - any unqualified non-conflicting WFXML/attribute
one or - - any non-conflicting WFXML from
more URI the listed namespaces
##targetNamespace ##local may appear in the above list,
with the obvious meaning -->
<!ELEMENT %anyAttribute; (%annotation;)?>
<!ATTLIST %anyAttribute;
namespace CDATA '##any'
processContents (skip|lax|strict) 'strict'
<!-- namespace is interpreted as for 'any' above -->
<!-- simpleType only if no type|ref attribute -->
<!-- ref not allowed at top level, name iff at top level -->
<!ELEMENT %attribute; ((%annotation;)?, (%simpleType;)?)>
<!ATTLIST %attribute;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
type %QName; #IMPLIED
use (prohibited|optional|required) #IMPLIED
form %formValues; #IMPLIED
<!-- type and ref are mutually exclusive.
name and ref are mutually exclusive, one is required -->
<!-- default for use is optional when nested, none otherwise -->
<!-- default and fixed are mutually exclusive -->
<!-- type attr and simpleType content are mutually exclusive -->
<!-- an attributeGroup is a named collection of attribute decls, or a
reference thereto -->
<!ELEMENT %attributeGroup; ((%annotation;)?,
(%attribute; | %attributeGroup;)*,
(%anyAttribute;)?) >
<!ATTLIST %attributeGroup;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
<!-- ref iff no content, no name. ref iff not top level -->
<!-- better reference mechanisms -->
<!ELEMENT %unique; ((%annotation;)?, %selector;, (%field;)+)>
<!ATTLIST %unique;
name %NCName; #REQUIRED