How can I use xsd: any with a namespace?

I need clarification in one of the scenarios <xsd:any>.

What if the attribute value namespace ##anyand attribute processContentsdo not exist (default value strict)?

What will happen here if the processor checks the elements for any circuits?

An example for clarification. Here is the XSD section:

......
<xsd:complexType name="reservedType"> <!-- a declaration for an element `reserved` -->
 <xsd:sequence>
  <xsd:any namespace="##any"/>
 </xsd:sequence>
</xsd:complexType>
..........

And here is the XML:

<c:reserved>
<message xmlns="unknown_schema">
 <msg>Hello</msg>
</message>
</c:reserved>

Whenever I try to validate this XML in the above diagram, I get:

The matching wildcard is strict, but no declaration can be found for element 'message'.

How does this happen, but the namespace ##any?

+3
source share
1 answer

The default processing model for xsd:anyis strict. So yes, you should set this element to laxor skip:

<xsd:sequence>
  <xsd:any namespace="##any" processContents="lax"/>
</xsd:sequence>

3.10.2 XML-. . , " ", .

+5

Source: https://habr.com/ru/post/1750375/


All Articles