我有以下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. 。当我与 wsdl2hgsoap 我正在接受消息:

笔记: <xs:choice> 带有嵌入式 <xs:sequence> 或者 <xs:group>防止使用工会

以上XSD正确吗?

有帮助吗?

解决方案

通常,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>

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top