-
XML Schema: Validating xsd:choice against another element in the schema
Hi:
I need to understand how I can validate the xsd:element choosen in an xsd:choice
to another element in the schema. Below is part of my schema.
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="stCommand">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Choce1" />
<xsd:enumeration value="Choice2" />
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Document1">
<xsd:complexType>
<xsd:sequenece>
<xsd:element name="Command" type="stCommand"/>
<xsd:choice>
<xsd:element name="Data1" type="xsd:string"/>
<xsd:element name="Data2" type="xsd:date"/>
<xsd:choice>
<xsd:sequenece>
</xsd:complexType>
</xsd:element>
</xsd:schema>
What I would like to see happen, is as follows. When Command = Choice1,
then the choice must be Data1. When Command = Choice2, then the choice must
be Data2.
How can I enforce this constraint using XML Schemas?
Thanks
Marc
)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|