Reputation: 1
Is there a way to define several attributes with fixed values and subelements for 2 elements with the same name?
<Root>
<element
attributeA="1"
attributeB="2">
<subElement/>
</element>
<element
attributeA="3"
attributeB="4">
<subElement/>
</element>
</Root>
I want any of this elements to be possible but the following element NOT to be allowed:
<element
attributeA="1"
attributeB="4">
<subElement/>
</element>
I know in xsd it is not possible to have 2 elements with the same name under one "parent". to create only on element and restrict it via enumeration does not seem to work since I have to avoid "mixed" forms. The names of the elements have to identical and they have to have the parent element.
Is there a solution I don't see or a workaround for this problem?
Upvotes: 0
Views: 117
Reputation: 163282
Such a model would violate the constraint "Element Declarations Consistent", which requires that if two element particles in a content model have the same name then they must have the same type.
You can do it in XSD 1.1, of course, using assertions.
Upvotes: 2