PROPOSAL: type assignment based on tag name and presence/absense of attributes

Earlier version of XML Schema (http://www.w3.org/1999/05/06-xmlschema-1/) and many existing XML schemas use distinct tagnames for declaration and reference.  The simplification initiative unified the
tag names but at the lost of a substantial degradation of the effectiveness of validation of schema documents.  This proposal recaptures the validation effectiveness of distinct declaration and
reference elements by allowing element to type binding to be conditional on the presence or absense of an attribute.
For example:
<attrGroup name="myattgroup">
	<attrDecl name="name"/>
	<attrDecl name="id"><datatypeRef name="ID"/></attrDecl>
</attrGroup>
<attrGroupRef name="myattgroup"/>
Since these distinct tag names where associated with different types the content models of the attrGroup and attrGroupRef were different.  You could put a attrDecl in an attrGroup but not in an
attrGroupRef.
The simplification initiative resulted in one tag name that could serve either as a reference or a declaration depending on whether the ref or name attribute was provided.  However this prevents
either DTD or schema processors to detect logically invalid constructs like:
<attributeGroup ref="myattgroup">
	<attribute name="name" type="NMTOKEN"/>
</attributeGroup>
Proposal:
Enhancing the <element> element with additional attributes "withAttribute" and "withoutAttribute" which is the name of an attribute that must (or must not) be present for the association of the tag
name to type be effective.
So for example, attribute would be reworked something like this
<type name="elemDecl" source="annotated" derivedBy="extension">
     <group order="choice" minOccurs="0">
      <element name="datatype" type="anonDatatype"/>
      <element name="type" type="anonType"/>
     </group>
     <group order="choice" minOccurs="0" maxOccurs="*">
        <element ref="unique"/>
        <element ref="key"/>
        <element ref="keyref"/>
     </group>
     <attributeGroup ref="typeRef"/>
     <attribute name="equivClass" type="QName"/>
     <attributeGroup ref="occurs"/>
     <attributeGroup ref="valueConstraint"/>
     <attribute name="nullable" type="boolean" default="false"/>
     <attribute name="abstract" type="boolean" default="false"/>
     <attribute name="final" type="boolean" default="false"/>
     <attribute name="exact" type="exactSet"/>
    </type>

<type name="elemRef" source="annotated" derivedBy="extension">
    <attribute name="ref" type="QName"/>
     <attributeGroup ref="occurs"/>
     <attributeGroup ref="valueConstraint"/>
</type>

<!--  the unique keys for element declarations would have to be redone  -->
<element name="element" withAttribute="name" type="elemDecl" equivClass="element"/>
<element name="element" withAttribute="ref" type="elemRef" equivClass="element"/>	

Effects:

This would allow a schema validator to more effective validate schema documents and other documents that use one tag name in different uses in the same context.  The implementation and performance
cost should be negligable. Explicit definition of the key attributes allows the determination of the proper type to use with only looking at the start element.

Received on Thursday, 6 January 2000 11:48:48 UTC