W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2003

Re-using XSD schema-for-schemas

From: <Simon.Cox@csiro.au>
Date: Thu, 26 Jun 2003 13:14:07 +0800
Message-ID: <2A2B2F12CF99EA4A898E2D4729441B41084A09@exwa2-per.wa.csiro.au>
To: <xmlschema-dev@w3.org>
Cc: <fellah@pcigeomatics.com>

We have an application where we wish to include some schema-like information within an instance document.  
Rather than create a new language, it seems smart to drop in some pieces from XSD.  
The mechanism appears straightforward:  simply import the schema-for-schemas

 <import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"> 

and then go for it.  This allows us to use xs:localSimpleType to indicate some constraints.  

However, the "facets" provided in the schema-for-schemas do not quite cover all the things we need.  
For example, we would like to add a "resolution" or "precision" facet to numeric values, something like this:

          <xs:restriction base="xs:integer">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="25"/>
            <myns:precision value="5"/>
          <xs:restriction base="xs:integer">
            <xs:minInclusive value="25"/>
            <xs:maxInclusive value="30"/>
            <myns:precision value="1"/>

Note that different precision's may be associated with different members of a union, so the information cannot be promoted to a container.  
Note also that a *pattern* will probably not do - a value of 23 is valid.

How to do this?    

Looking inside s-for-s, the "facets" are attached through a model group 

<xs:group name="facets">
<xs:element ref="xs:minExclusive"/>
<xs:element ref="xs:minInclusive"/>
<xs:element ref="xs:maxExclusive"/>
<xs:element ref="xs:maxInclusive"/>
<xs:element ref="xs:totalDigits"/>
<xs:element ref="xs:fractionDigits"/>
<xs:element ref="xs:length"/>
<xs:element ref="xs:minLength"/>
<xs:element ref="xs:maxLength"/>
<xs:element ref="xs:enumeration"/>
<xs:element ref="xs:whiteSpace"/>
<xs:element ref="xs:pattern"/>

Now XSD's "redefine" does apply to model groups, so I guess we could extend 
the group with the additional facets required, and then these would become 
available within localSimpleType.  
But this would involve tinkering with components in the XSD namespace.  
That doesn't look like such a smart idea.  

Is there another mechanism that we could use?   
Maybe declare a new facet and add it to a substitution-group headed 
by one of the existing facets?

[N.B. There is an annotation on the facets group:
       We should use a substitution group for facets, but
       that's ruled out because it would allow users to
       add their own, which we're not ready for yet.
So obviously the W3C WG have at least briefly considered this use-case.  
What to do while waiting for them to revisit this issue?]

Simon Cox

Simon.Cox@csiro.au  CSIRO Exploration & Mining
26 Dick Perry Avenue, Kensington WA 6151
PO Box 1130, Bentley WA 6102  AUSTRALIA
T: +61(8) 6436 8639  F: +61(8) 6436 8555  C: +61(4) 0330 2672
Received on Thursday, 26 June 2003 01:14:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:11 UTC