Adam Howard
Adam Howard

Reputation: 400

XML schema - namespace choice ambiguity

I have the following choice sequence as part of an XML schema. Ideally, I want a sequence where either:

  1. Elements from my:namespace must be strictly parsed.
  2. Elements from any other namespace, excluding ##targetNamespace and my:namespace, should be skipped during parsing/validation.
<xs:sequence>
    <xs:choice>
        <xs:any namespace="my:namespace"/>
        <xs:any namespace="##other" processContents="skip"/>
    </xs:choice>
</xs:sequence>

However, of course, this schema is invalid: my:namespace is a member of ##other, so parsing is ambiguous. Attempting to use this schema yields a unique particle attribution violation. Is there any other way to achieve what I've described?

Upvotes: 0

Views: 63

Answers (1)

Michael Kay
Michael Kay

Reputation: 163262

XSD 1.1 allows xs:any to have an explicit list of namespaces to be included or excluded.

So many questions follow the pattern "can I do this in XSD" and have the answer "yes, but you need XSD 1.1"...

Upvotes: 1

Related Questions