【问题标题】:The namespace of element 'enumeration' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'元素“枚举”的命名空间必须来自模式命名空间“http://www.w3.org/2001/XMLSchema”
【发布时间】:2015-06-21 08:21:14
【问题描述】:

验证 xsd 中的枚举元素时出现此错误。

<xsd:restriction base="xsd:unsignedInt">
               <enumeration value="4">
       </enumeration>
        </xsd:restriction>

请帮我解决这个问题。

 s4s-elt-schema-ns: The namespace of element 'enumeration' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.

【问题讨论】:

    标签: xsd xsd-validation xjc


    【解决方案1】:

    将命名空间前缀xsd:添加到enumeration

    <xsd:restriction base="xsd:unsignedInt">
      <xsd:enumeration value="4"/>
    </xsd:restriction>
    

    【讨论】:

    • 你是对的。但如果我传递了特殊字符,它是允许的。它没有使用字符串字符进行验证。
    • 您显然必须在 enumeration 上加上 xsd: 前缀才能克服错误。如果您在使用特殊字符时遇到更多问题,则必须为您的问题添加更多细节(或者,更好的是,提出一个新问题),我们将尽力帮助解决该问题。请务必发布一个显示问题的最小但完整的示例(XML 和 XSD)。谢谢。
    【解决方案2】:

    enumeration 元素需要绑定 XML Schema。您需要添加前缀,即xsd,如下所示:

    <xsd:enumeration>
    

    【讨论】:

    • 好的。不过看起来你是最快的。
    • 你显然已经在回答了,所以我们称之为平局。
    • 这是正确的。我同意。但是当我传递字母或特殊字符时。它没有验证。它允许。
    猜你喜欢
    • 2011-06-22
    • 2016-12-03
    • 2012-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-27
    • 1970-01-01
    相关资源
    最近更新 更多