Derivation by restriction in XML Schema

The current formulation of derivation by restriction
appears to have a couple of shortcomings:

It is not possible to derive a complex type that
is both a restriction and extension of a base type
without using two separate derivation.

It does not appear possible to restrict the value
of an attribute from another namespace that
was introduced using a <attributeGroup ref="other:attgroup"/>
For example, if would not be possible to restrict
xml:lang to a list of supported languages or one of the
xlink attributes to a subset of supported values.

By performing restriction using the same elements
and data model as declaration there are ample
opportunities for inconsistency between the
initial declaration and the restriction.  For 
instance, the restriction of a datatype may
imply a different base type than the initial
definition or a restriction of the content
may introduce content that is inconsistent
with the initial content model.

The method of addressing fragments of element content
of a type for restriction is poorly defined and
complicated.

The capabilities mentioned in the primer of renaming
elements and attributes seem way over-the-top.
However, you could still use the approach described
below by adding adding a distinct attribute for the
new name to the restriction element and attribute
elements.

It appears that these problems may be eliminated by
allowing <complexType> have a <restrict> child element
and defining restrict-scoped <element>, <attribute>,
et al that only allow restrict-appropriate attributes and 
content and removing the derivedBy attribute.  The attribute
element's name attribute is a QName that allows you to 
reference attributes introduced by attribute group
reference, it would not attempt to restrict attributes
encountered that were allowed only through a <anyAttribute>
element.  The match attribute on <element> et al is an 
subset XPath that operates on an InfoSet that is the 
base type's expanded content model (all group ref's and
ancestor content brought in line).


The following is my attempt to write this in the current
schema for schemas.

<element name="restrict">
    <complexType base="annotated">
	<choice minOccur="0" maxOccur="*">
        	<element name="element">
	    		<complexType base="annotated">
				<element ref="facet" minOccur="0" maxOccur="*"/>
				<attribute name="match" type="XPathApprox" minOccur="1"/>
				<attributeGroup ref="occurs"/>
				<attributeGroup ref="valueConstraint"/>
	    		</complexType>
		</element>
        	<element name="choice">
	    		<complexType base="annotated">
				<attribute name="match" type="XPathApprox" minOccur="1"/>
				<attributeGroup ref="occurs"/>
	    		</complexType>
		</element>
        	<element name="sequence">
	    		<complexType base="annotated">
				<attribute name="match" type="XPathApprox" minOccur="1"/>
				<attributeGroup ref="occurs"/>
	    		</complexType>
		</element>
        	<element name="all">
	    		<complexType base="annotated">
				<attribute name="match" type="XPathApprox" minOccur="1"/>
				<attributeGroup ref="occurs"/>
	    		</complexType>
		</element>
        	<element name="any">
	    		<complexType base="annotated">
				<attribute name="match" type="XPathApprox" minOccur="1"/>
				<attributeGroup ref="occurs"/>
	    		</complexType>
		</element>
	</choice>
        <element name="attribute" minOccur="0" maxOccur="*">
	    <complexType base="annotated">
		<!--  you can have any number of additional facets
                         that constrain this restriction   -->
		<element ref="facet" minOccur="0" maxOccur="*"/>
		<!--   QName so that you can refer to other namespaces -->
		<attribute name="name" type="QName" minOccur="1"/>
		<attributeGroup ref="occurs"/>
		<attributeGroup ref="valueConstraint"/>
	     </complexType>
	</element>
	<!--  in this context it prohibits the attributes in the listed namespaces  -->
	<element name="anyAttribute" minOccur="0">
		<complexType>
			<attribute name="namespace" type="namespaceList"/>
		</complexType>
	</element>
    </complexType>
</element>

Received on Monday, 6 March 2000 14:27:32 UTC