XML Schema: New Item For Discussion - Variant Complex Types

Recommend:  New Lexical Item <xs:variant> to define
a choice of complex type definitions based on some key.

I currently see no specification to accommodate variants
of complex types other than to declare items as optional.

Ongoing Development:

A significant interface development activity is deploying
an application that makes use of an attribute value to
select a defining namespace variant for the named complex
data structure.

Example:

<xs:element name="variantData" type="variantDataType/>

<xs:complexType name="variantDataType">
  <xs:variant>
   <xs:complexType ref="variantType1" Key="1"/>
   <xs:complexType ref="variantType2" Key="2"/>
   <xs:complexType ref="variantType3" Key="3"/>
   <xs:complexType ref="variantType3" Key="A"/>
  </xs:variant>
  <xs:attribute name="Key" type="xs:token" use="required"/>
</xs:complexType>

<xs:complexType name="variantType1">
  <xs:complexContent>
   <!-- declaration components -->
  </xs:complexContent>
  <xs:attribute name="Key" use="fixed" value="1"/>
</xs:complexType>

<xs:complexType name="variantType2">
  <xs:complexContent>
   <!-- declaration components -->
  </xs:complexContent>
  <xs:attribute name="Key" use="fixed" value="2"/>
</xs:complexType>

<xs:complexType name="variantType3">
  <xs:complexContent>
   <!-- declaration components -->
  </xs:complexContent>
  <xs:attribute name="Key" type="xs:token" use="required"/>
</xs:complexType>

The variant subtypes are completely unrelated except
that they are selected by a value specified by the
{Key} attribute.  The element, however, has a fixed
name in the application, the content is interpreted
according to the application rules specified by the
{Key}.

This issue may force a delay in namespace resolution
of the variantType until after the value of {Key} has
been determined by the application.  The current
application is not using namespace validating parsers.

Sincerely,
Steven J. Hathaway
Oregon State Police
Email: <steven.j.hathaway@state.or.us>



  

Received on Thursday, 15 March 2007 13:52:44 UTC