【问题标题】:XML xs::assert in complex type复杂类型的 XML xs::assert
【发布时间】:2014-03-17 12:55:18
【问题描述】:

我正在尝试在我的 XML 架构中引入条件强制字段,但我收到一个错误,即 xs:assert 在上下文中无效...有什么建议可以帮忙吗?

附加信息:我正在使用 Xerces 3.11 (C++) 来解析 xml)

<?xml version="1.0" encoding="iso-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="configuration" type="configurationType"/>

  <xs:complexType name="configurationType">
    <xs:sequence>
      <xs:element name="application" minOccurs="1" maxOccurs="unbounded" type="appType" />
      <xs:element name="command" minOccurs="1" maxOccurs="unbounded" type="commandType"/>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="appType">
    <xs:attribute name="name" type="xs:string" use="required" />
    <xs:attribute name="hostname" type="xs:string" use="required" />
    <xs:attribute name="port" type="xs:positiveInteger" use="required" />
    <xs:attribute name="group" type="xs:string" use="required" />
    <xs:assert test="@hostname or @port != 4"/>
  </xs:complexType>

  <xs:complexType name="commandType">
    <xs:attribute name="name" type="xs:string" use="required" />
    <xs:attribute name="target" type="xs:string" use="required" />
    <xs:attribute name="parameter" type="xs:string" use="optional" />
  </xs:complexType>

</xs:schema>

【问题讨论】:

    标签: xml xml-parsing xsd schema


    【解决方案1】:

    Xerces 3.1.1 C++ 不支持 XSD 1.1。这是根本原因。

    XSDL 1.1 实验处理器在 Xerces-J(仅限 Java)上是 introduced,从版本 2.10.0 开始。

    【讨论】:

    • 谢谢,这很有意义。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-19
    • 2019-02-05
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    相关资源
    最近更新 更多