Вопрос

I am trying to introduce conditional mandatory fields in my XML schema but I am getting an error that xs:assert isn't valid in context... any suggests to help please?

Additional information: I am using Xerces 3.11 (C++) to parse the 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>
Это было полезно?

Решение

Xerces 3.1.1 C++ does not support XSD 1.1. This is the root cause.

XSDL 1.1 experimental processor was introduced at Xerces-J (Java only) starting from version 2.10.0.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top