【问题标题】:xs:choice embedded in xs:sequence prevents the use of a unionxs:choice 嵌入在 xs:sequence 中,防止使用联合
【发布时间】:2010-10-18 20:25:30
【问题描述】:

我有以下xsd

<xsd:complexType name="myID">
    <xsd:choice>
        <xsd:element name="testID" type="priv:testID"/>
        <xsd:sequence>
            <xsd:element name="newID" type="priv:newID"/>
            <xsd:element name="testID" type="priv:testID" minOccurs="0"/>
        </xsd:sequence>
    </xsd:choice>
</xsd:complexType>

一切都在priv 命名空间下。问题是看起来myID 是一个联合。它可能是testID 或带有newIDtestID 的序列。当我使用来自gsoapwsdl2h 编译它时,我正在接受消息:

注意:&lt;xs:choice&gt; 嵌入 &lt;xs:sequence&gt;&lt;xs:group&gt; 阻止使用联合

上述 XSD 是否正确?

【问题讨论】:

    标签: web-services soap xsd gsoap xsd-validation


    【解决方案1】:

    一般而言,XML 类型myID 可以按照您的描述进行声明。冲突可能与您对类型 priv:testIDpriv:testID 的定义有关,您未包括该定义。例如架构

    <?xml version="1.0" encoding="utf-8"?>
    <xsd:schema targetNamespace="http://www.ok-soft-gmbh.com/xml/xsd/1.0/XMLSchema.xsd"
        elementFormDefault="qualified"
        xmlns:priv="http://www.ok-soft-gmbh.com/xml/xsd/1.0/XMLSchema.xsd"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    >
        <xsd:simpleType name="testID">
            <xsd:restriction base="xsd:string"/>
        </xsd:simpleType>
        <xsd:simpleType name="newID">
            <xsd:restriction base="xsd:string"/>
        </xsd:simpleType>
        <xsd:complexType name="myID">
            <xsd:choice>
                <xsd:element name="testID" type="priv:testID"/>
                <xsd:sequence>
                    <xsd:element name="newID" type="priv:newID"/>
                    <xsd:element name="testID" type="priv:testID" minOccurs="0"/>
                </xsd:sequence>
            </xsd:choice>
        </xsd:complexType>
        <xsd:element name="root" type="priv:myID"/>
    </xsd:schema>
    

    将是正确的。因此,如果存在错误,则不在您发布的部分中。

    【讨论】:

    • 你的 XSD 比我的更完整。问题是“在 xsd:choice 中嵌套序列是否合法”?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-31
    • 2019-02-01
    • 1970-01-01
    • 2013-10-14
    • 1970-01-01
    相关资源
    最近更新 更多