Reputation: 23
I am working on a XSD validation code and I am trying to figure out how to validate a XML file that has
<root>
<elementA attribute1=ID>
...
</elementA>
<elementA attribute2=ID>
...
</elementA>
</root>
and I want to make the XSD where it validates the same element based off the attribute name and makes some of the child element optional for attribute1
while required for attribute2
.
Note that "..." is the same elements with some fields being optional for attribute1
.
Upvotes: 2
Views: 563
Reputation: 163595
In XSD 1.0 the type of an element can depend only on the element name, and not on its attributes. XSD 1.1 removes this restriction with a facility called "conditional type assignment". XSD 1.1 is currently implemented only in Xerces and Saxon.
Upvotes: 2