I am trying to adjust my xsd that it allows as child one element with the name processName and otherwise any element.
For that I prepared a small complexType:
<complexType name="configType">
<!-- <xsd:choice> -->
<sequence>
<element name="processName" type="string" maxOccurs="1"/>
<xsd:any minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<!-- </xsd:choice> -->
</complexType>
My problem is that it doesn't prevent any other occurrence of the processName:
<config>
<process:processName></process:processName>
<test></test>
<test2></test2>
<process:processName></process:processName>
</config>
I have tried to use choice but it ends with the validation error
processName and WC[##any] (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.
The rule isn't active any more in XSD v 1.1, but all my XML files are version 1.0. But I think it isn't possible to check with newer schema version an older file.
This particular example no longer violates the Unique Particle Attribute constraint in XML Schema version 1.1, which disambiguates it by saying that when an element matches both an element particle and a wildcard, the element particle wins. However, the UPA constraint itself remains in version 1.1.
Is it possible to enforce only one time occurence of processName?
Thanks for any hints.
EDIT:
With some hints from ColdFusion I was able to create a piece of XSD1.1 schema which allows the ambigous declaration:
<sequence>
<element name="processName" type="string" minOccurs="0" maxOccurs="1"/>
<xsd:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</sequence>
Now it is possible to have multiple times processName.