How can I use xsd:any with a namespace?
I need a clarification on one of scenarios of <xsd:any>
.
What if namespace
attribute's value is ##any
and the attribute processContents
doesn't exist (the default value is strict
)?
What will be the case here, Should the processor validate the elements against any schemes?
Example for clarification. Here's XSD section:
......
<xsd:complexType name="reservedType"> <!-- a declaration for an element `reserved` -->
<xsd:sequence>
<xsd:any namespace="##any"/>
</xsd:sequence>
</xsd:complexType>
..........
And here's the XML:
<c:reserved>
<message x开发者_高级运维mlns="unknown_schema">
<msg>Hello</msg>
</message>
</c:reserved>
Whenever I try to validate this XML against the above schema, I get:
The matching wildcard is strict, but no declaration can be found for element 'message'.
How this come, and the namespace is ##any
?
The default processing model for xsd:any
is strict. So yes, you will have to set this element to lax
or skip
:
<xsd:sequence>
<xsd:any namespace="##any" processContents="lax"/>
</xsd:sequence>
Please refer to Section 3.10.2 of the XML Schema specification. See the table just below, on "Wildcard Schema Components", in particular the process contents attribute.
精彩评论