I have this xsd file:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="http://HIDDEN/Queues"
xmlns="http://HIDDEN/Queues">
<xs:complexType name="Queue">
<xs:sequence>
<xs:choice>
<xs:sequence>
<xs:element fixed="1" name="id" type="xs:long"/>
<xs:element fixed="a" name="name" type="xs:string"/>
</xs:sequence>
<xs:sequence>
<xs:element fixed="2" name="id" type="xs:long"/>
<xs:element fixed="b" name="name" type="xs:string"/>
</xs:sequence>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:schema>
The goal is that an element with the type Queue should be able to look like this:
<Queue>
<id>1</id>
<name>a</name>
</Queue>
but as soon as either id or name do not match togehter (e.g id=2 name=a) it should fail.
The part im confused abt is this error:
"http://HIDDEN/Queues":id and "http://HIDDEN/Queues":id (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.
I mean i see what its referencing to but those are elements that cant exist at the same time so idk how to fix that. One idea i had was to jus make id and name as attributes but my boss said i cant do that (dont ask me why).
Do any of you know any other approaches? thanks in advance!
Here is a solution based on XSD 1.1 that is using an assert statement to enforce correct combinations of id and name values.
Input XML
XSD 1.1