2010-10-18 51 views
0

的,我有以下XSDXS:選擇嵌入的xs:順序禁止使用工會

<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是一個聯盟。它可能是testIDnewIDtestID的序列。當我與wsdl2h編譯它從gsoap我走的消息:

注:<xs:choice>嵌入 <xs:sequence><xs:group> 禁止使用工會

的是上述XSD是否正確?

回答

0

一般而言,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> 

將是正確的。所以如果存在錯誤,它不在你發佈的部分。

+0

您的XSD比我的完整。問題是「在xsd:choice中嵌套序列是否合法?」? – cateof 2010-10-19 07:10:35

+0

@cateof:是的,這是合法的。 – Oleg 2010-10-19 07:12:40