Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: XSD Constraints XSD ConstraintsTo: NULL Date: 2/1/2008 2:41:00 AM Hello, I'm writing a schema, and I want to apply some contraints to the combination of values that can be supplied for the attributes for one of the elements. The problem concerns the Operation element in the xml fragment below. The element has two attrbiutes, and I want to apply some rules that ensure that the values provided are in agreement with one another. For example, I want ensure the CREATE, UPDATE and DELETE values for the Operation attribute are provided with a Sequence number, but that the CREATEUPDATE value of Operation attribute is not have a Sequence Number provided. I want to <b>allow</b> only the following combinations: <ns1:Operation Operation='CREATE' Sequence=(any +ve int)/> <ns1:Data>Data</ns1:Data> ... <ns1:Operation Operation="UDPATE' Sequence=(any +ve int)/> <ns1:Data>Data</ns1:Data> ... <ns1:Operation Oprtation='DELETE' Sequence=(any +ve int)/> <ns1:Data>Data</ns1:Data> ... <ns1:Operation Operation='CREATEUPDATE'/> <ns1:Data>Data</ns1:Data> but <b>prevent<b/> the following xml <ns1:Operation Operation='CREATEUPDATE' Sequence=(any +ve int)/> <ns1:Data>Data</ns1:Data> Does anyone know how this is achieved? --Fragment-- <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns="http://www.world.com" xmlns:xs="http://www.w3.org/ 2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:ns1="http://world.com/schema.xsd" targetNamespace="http:// world.com/schema.xsd" elementFormDefault="qualified" version="1.5"> <xs:element name="ScriptMark" type="ns1:MarkType"/> <xs:complexType name="MarkType"> <xs:sequence> <xs:element name="Operation" type="ns1:OperationType"/> <xs:element name="Data" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="OperationType"> <xs:attribute name="Operation" type="ns1:OpType" use="required"/> <xs:attribute name="Sequence" type="ns1:SequenceType" use="optional"/ > </xs:complexType> <xs:simpleType name="OpType"> <xs:restriction base="xs:string"> <xs:enumeration value="CREATEUPDATE"/> <xs:enumeration value="CREATE"/> <xs:enumeration value="UPDATE"/> <xs:enumeration value="DELETE"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="SequenceType"> <xs:restriction base="xs:int"> <xs:minInclusive value="0"/> </xs:restriction> </xs:simpleType> </xs:schema> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
