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: <5.1.0.14.1.20030306113319.02446e08@localhost>
To: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>




Hello,

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">
     <value>1</value>
</parameter>

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:complexType>
         <xs:attribute name="name" type="xs:string" use="required" />
         <xs:attribute name="type" use="required">
             </xs:annotation>
             <xs:simpleType>
                 <xs:restriction base="xs:NMTOKEN">
                     <xs:enumeration value="int" />
                     <xs:enumeration value="float" />
                     <xs:enumeration value="string" />
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>

         <!-- 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>
         <xs:condition attribute="type" equals="float">
             <xs:element name="value" type="xs:float" />
         </xs:condition>
         <xs:condition attribute="type" equals="string">
             <xs:element name="value" type="xs:string" />
         </xs:condition>

     </xs:complexType>
</xs:element>

Thanks,
--phil 
Received on Thursday, 6 March 2003 13:35:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:13:01 GMT