I have this in XML:
<generator Mode="High">
<GenMode name="Normal" kV="90" mA="0.5" />
<GenMode name="High" kV="160" mA="0.7" />
</generator>
generator/@Mode
should be valid only if it matches one of the generator/GenMode/@name
. Is it possible with XSD 1.0?
Now I'm using this rules in xsd file for this element:
<xs:element name="generator">
<xs:complexType>
<xs:sequence>
<xs:element name="GenMode" maxOccurs="unbounded" type="GenModeType" />
</xs:sequence>
<xs:attribute name="Mode" use="required" type="xs:string"/>
</xs:complexType>
<xs:key name="GenModeName">
<xs:selector xpath="GenMode"/>
<xs:field xpath="@name"/>
</xs:key>
</xs:element>
<xs:complexType name="GenModeType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="kV" use="required" type="xs:integer"/>
<xs:attribute name="mA" use="required" type="xs:decimal"/>
</xs:complexType>
I found the way to validate the attribute value with XSD 1.0 and it should not refer only to the first child element.