Hello to all experts.
The problem that i have is related with this xml:
<RootNode>
<SubNode type="test1">
<AgainSubNode />
<AgainSubNode />
</SubNode>
<SubNode type="test2">
<AgainSubNode />
<AgainSubNode />
</SubNode>
I want to validate the xml using only xsd schema. The validation i have problem with is validating the xml file against the value of the attribute type. I have declared it as
<xs:simpleType name="Types">
<xs:restriction base="xs:string">
<xs:enumeration value="test1" />
<xs:enumeration value="test2" />
</xs:restriction>
</xs:simpleType>
</RootNode>
Is it possible to write something like this:
- if type = test1 then SubNode must have only one AgainSubNode node
- if type = test2 then subNode must have at least 3 AgainSubNode nodes
Thanks
You want the content type to be different depending on the value of an attribute
That is a so called "co-occurence constraint"
You cannot model that in W3C schema
For that you should use Schematron (www.schematron.com)
or add a validation layer using XSLT or something
cheers
Geert