Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSD Constraints

From: Steve Fletcher <ste.fletch@-----.--->
To: 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>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent