Tuesday, September 16, 2008

xs:any Unique Particle Attribution violation

So, i have been trying my hand at creating XSDs for a project i am working on.. While creating it, there came a situation where in, i had to put in an "" element in the XSD.

All was fine and green until the customer complains of an validator error that happens in few of the XSDs that contain this xs:any element. It goes something like this..

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.

After a few hours of searching the internet, this is what i came across..
. Since the xs:any can be used to introduce any arbitary element, it will create an ambiguous situation if the xs:any element is placed after an element whose presence in the scheme is arbitary (i.e. minOccurs=0).

Hence, while parsing, your parser gets confused and cannot parse the xsd. So, the xs:any element should always come after an element whose minOccurs=0. More information here at:

http://en.wikipedia.org/wiki/Unique_Particle_Attribution

No comments: