xsd - XML Schema - Validate one attribute, based on the value of another -


i want able validate attribute in element, based on value of attribute. this.

<root>     <vehicle type="unicycle" numwheels="1" />     <vehicle type="bicycle" numwheels="2" /> </root> 

the requirement if vehicle types 'unicycle', numwheels must 1. otherwise don't care how many wheels has.

i have starting point type, want impose restriction.

<!-- number of wheels restrictions --> <xsd:simpletype name="numberofwheelstype">     <xsd:restriction base="xsd:integer">         <xsd:mininclusive value="1"/>     </xsd:restriction> </xsd:simpletype> 

i must confess not quite sure start create restriction want, guidance appreciated.

i using xmllint validate schema think restrict me xml schema 1.0 (correct me if wrong, because cannot prove 1 way or other).

cross-constraints across attribute values require xsd 1.1, , correctly surmise, xmllint supports xsd 1.0. need add other validation technology pipeline: either xsd 1.1, or schematron, or custom validator written in xslt.


Comments