xsd 验证以允许意外元素 [英] xsd validation to allow unexpected elements

查看:29
本文介绍了xsd 验证以允许意外元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的帮助:'(我的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆