xsd 验证以允许意外元素 [英] xsd validation to allow unexpected elements
问题描述
我需要你的帮助:'(我的 XSD 验证有问题,它返回带有意外元素的错误.但我想允许并跳过任何意外元素.我尝试使用
但它在
和
I need your help :'(
I have a problem with XSD validation, It returns error with Unexpected elements. But i want to allow and skip any unexpected elements. I try to use <xs:any>
but its not allowed under <xs:all>
and <xs:element ref
doesn't work, I have no idea how to fix it :
<xs:complexType>
<xs:all>
<xs:any processContents="lax" maxOccurs="unbounded" minOccurs="0" />
<xs:element name="id" type="xs:integer" />
<xs:element name="lastname" type="xs:string" />
<xs:element name="firstname" type="xs:string" />
<xs:element ref="adress" />
<xs:element ref="phone" />
</xs:all>
例如,当我收到意外元素性别"时,它会返回错误.你知道哪个标签可以提供帮助吗?或任何解决方案.在此先感谢各位.
It returns error for example when I got unexpected elements "gender". DO you know which tag can be help ? or any solutions. Thanks in advance guys.
推荐答案
将
更改为
,如http://www.w3schools.com/schema/schema_complex_any.asp 它会起作用.>
Change <xs:all>
to <xs:sequence>
as specified in http://www.w3schools.com/schema/schema_complex_any.asp it will work.
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:any minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
这篇关于xsd 验证以允许意外元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!