开发者

Unique Particle Attribution Exception when i use <xsd:any> within <xsd:choice>

开发者 https://www.devze.com 2023-03-27 01:46 出处:网络
I need either apps element or other element defined i开发者_JS百科n some other xsd (which I am importing through <xsd:any> ) or both. I have used choice but it is throwing Unique Particle Attrib

I need either apps element or other element defined i开发者_JS百科n some other xsd (which I am importing through <xsd:any> ) or both. I have used choice but it is throwing Unique Particle Attribution Exception.

<xsd:sequence>
    <xsd:choice minOccurs="1" maxOccurs="unbounded">
        <xsd:element name="apps" />
        <xsd:any minOccurs="0" namespace="##local" />
    </xsd:choice>
</xsd:sequence>


This won't work because the XML processor does not know where your apps alement belongs to. xsd:element or xsd:any. It cannot do a look-ahead. Choose another namespace.


Unique Particle Attribution helps prevent ambiguity - where you have the apps element defined alongside the xsd:any, it is ambiguous whether the apps element is associated with the specific element declaration (xsd:element name="apps") or with the wildcard (xsd:any).

Your question doesn't give enough detail for a full answer - are the other non "apps" elements completely unspecified? E.g. is it literally any element, or is it "apps" and other well defined choices? If you have can defined the other elements then add those as specified choices, otherwise you may as well use xsd:any without the need to define the "apps" element.


Your schema is legal in XSD 1.1, which resolves the ambiguity by saying that a match against an explicit element declaration wins over a match against a wildcard. In XSD 1.0, however, you can't have a choice between a specific element and a wildcard if the namespaces allowed by the wildcard include the namespace of the specific element.

0

精彩评论

暂无评论...
验证码 换一张
取 消