W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > January to March 2003

Enforcing 'conditions' without using XSLT

From: Hall, Philip <phall@spss.com>
Date: Thu, 06 Mar 2003 11:33:46 -0700
Message-Id: <>
To: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>


I'm trying to figure out if the new draft for schemas supports 'conditions' 
i.e. I have the following XML snippet;

<parameter name="burt" type="int">

In my schema, I have the 'type' attribute as a NMTOKEN with for example 
'int | float | string' as enumerations.

I'd like to be able to specify that the schema type of the value node 
reflects the value of this 'type' attribute, to enforce that when the XML 
states the parameter type attribute is 'x' that the child value node *is* 
of type 'x'

Kind being able to write in the schema;

<xs:element name="Parameter">
         <xs:attribute name="name" type="xs:string" use="required" />
         <xs:attribute name="type" use="required">
                 <xs:restriction base="xs:NMTOKEN">
                     <xs:enumeration value="int" />
                     <xs:enumeration value="float" />
                     <xs:enumeration value="string" />

         <!-- here's where the actual data type is set for the value 
element -->

         <xs:condition attribute="type" equals="int">
             <xs:element name="value" type="xs:int" />
         <xs:condition attribute="type" equals="float">
             <xs:element name="value" type="xs:float" />
         <xs:condition attribute="type" equals="string">
             <xs:element name="value" type="xs:string" />


Received on Thursday, 6 March 2003 13:35:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:08:59 UTC