I'm working on a XSD schema and I'm facing this problem, I want an element X to have only one attribute out of the two possible or no attribute at all for example
<a Attribute1="something"/> --> validates
<a attribute2="another thing"/> --> validates
<a attribute1="something" element2="another thing"/> --> validation failed.
<a/> --> validates
I tried something but it allows the two attributes and that's what a want to avoid
<xsd:element name ="a">
<xsd:complexType>
<xsd:attribute name ="attribute1" type="xsd:string" use="optional"/>
<xsd:attribute name ="attribute2" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
I also tried this piece of code put it doesn't validate a 0 attribute tag
<xsd:key name="key">
<xsd:selector xpath="."/>
<xsd:field xpath="@attribute1|@attribute2"/>
</xsd:key>
anybody with a solution or an idea?
No comments:
Post a Comment