Re: XML Schema: New Item For Discussion - Variant Complex Types

A facility to do essentially this is under serious discussion for Schema 
1.1.  It's being tracked internally as the feature named "Conditional Type 
Assignment".  The likely form would be that what you call the "key" would 
be an XPath predicate that could trigger on the existence and/or values of 
one or more attributes on the element to be typed.

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------








"Steven J Hathaway" <Steven.J.Hathaway@state.or.us>
Sent by: www-xml-schema-comments-request@w3.org
03/14/2007 06:33 PM
 
        To:     <www-xml-schema-comments@w3.org>
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        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 14:02:34 UTC