我需要对其中一个场景进行澄清<xsd:any>.
如果namespace属性值为##any且属性processContents不存在(默认值为strict),该怎么办?
这将是什么情况,处理器是否应该针对任何方案验证元素?
澄清的例子.这是XSD部分:
......
<xsd:complexType name="reservedType"> <!-- a declaration for an element `reserved` -->
<xsd:sequence>
<xsd:any namespace="##any"/>
</xsd:sequence>
</xsd:complexType>
..........
Run Code Online (Sandbox Code Playgroud)
这是XML:
<c:reserved>
<message xmlns="unknown_schema">
<msg>Hello</msg>
</message>
</c:reserved>
Run Code Online (Sandbox Code Playgroud)
每当我尝试针对上述模式验证此XML时,我得到:
The matching wildcard is strict, but no declaration can be found for element 'message'.
Run Code Online (Sandbox Code Playgroud)
这是怎么来的,命名空间是##any?
默认处理模型xsd:any 是严格的.所以,是的,您必须将此元素设置为lax或skip:
<xsd:sequence>
<xsd:any namespace="##any" processContents="lax"/>
</xsd:sequence>
Run Code Online (Sandbox Code Playgroud)
请参阅XML Schema规范的第3.10.2节.请参阅下面的表,"通配符架构组件",特别是进程内容属性.
| 归档时间: |
|
| 查看次数: |
3280 次 |
| 最近记录: |