Domanda

Ho il seguente 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>

Tutto è sotto priv namespace. Il problema è che sembra che myID è un'unione. Potrebbe essere una testID o di una sequenza con newID e testID. Quando compilo con wsdl2h da gsoap sto prendendo il messaggio:

  

Nota: <xs:choice> con incorporato   <xs:sequence> o <xs:group>   impedisce l'uso di un'unione

È possibile che questo XSD corretto?

È stato utile?

Soluzione

In generale il tipo XML myID può essere dichiarato come hai descritto. Il conflitto esiste probabilmente in connessione con la tua definizione del tipo priv:testID e priv:testID quale definizione non incluso. Per esempio lo schema

<?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>

sarà corretto. Quindi, se un'esiste l'errore, non è nella parte che hai postato.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top