XML xs::复杂类型中的断言

XML xs::复杂类型中的断言,xml,xml-parsing,xsd,schema,Xml,Xml Parsing,Xsd,Schema,我试图在XML模式中引入条件必填字段,但我得到一个错误,xs:assert在上下文中无效。。。有什么建议可以帮忙吗 附加信息:我正在使用Xerces 3.11(C++)解析xml) < /代码> XeSer3.3.1.1 C++不支持XSD 1.1。这是根本原因 XSDL 1.1实验处理器是Xerces-J(仅限Java)从2.10.0版开始的。谢谢,这很有意义。 <?xml version="1.0" encoding="iso-8859-1" ?> <xs:schema

我试图在XML模式中引入条件必填字段,但我得到一个错误,xs:assert在上下文中无效。。。有什么建议可以帮忙吗

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



< /代码> XeSer3.3.1.1 C++不支持XSD 1.1。这是根本原因


XSDL 1.1实验处理器是Xerces-J(仅限Java)从2.10.0版开始的。

谢谢,这很有意义。
<?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>