2014-10-30 212 views
0

我有服務,有如下格式的請求的方法:在提供XML Schema屬性名稱相同但屬性值不同?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:com="http://com.org.srv"> 
<soapenv:Header/> 
    <soapenv:Body> 
    <com:methodName> 
    <com:someParam>value</com:someParam> 
    <com:param name="firstPoint"> 
     <com:param name="code">value</com:param> 
    </com:param> 
    <com:param name="firstPointDesc"> 
     <com:param name="pName">value</com:param> 
     <com:param name="pLo">value</com:param> 
    </com:param> 
    <com:param name="endPoint"> 
     <com:param name="code">value</com:param> 
    </com:param> 
    <com:param name="endPointDesc"> 
     <com:param name="pName">value</com:param> 
     <com:param name="pLo">value</com:param> 
    </com:param> 
    <com:param name="bunch"> 
     <com:param name="temperature">val</com:param> 
     <com:param name="humidity">val</com:param> 
     <com:param name="pressure">val</com:param> 
    </com:param> 
    </com:methodName> 
</soapenv:Body> 
</soapenv:Envelope> 

此信息,是,我需要來形容它在XSD文件中蝕。 我曾嘗試:

<element name="methodNameRequest"> 
    <complexType> 
     <sequence maxOccurs="1" minOccurs="1"> 
      <element name="someParam" type="string" maxOccurs="1" 
       minOccurs="1"> 
      </element> 
      <element name="deviceId" type="string"></element> 
      <element name="param" maxOccurs="1" minOccurs="1"> 
       <complexType> 
        <sequence> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="code" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
        </sequence> 
        <attribute name="name" type="string" 
         default="firstPoint" /> 
       </complexType> 
      </element> 
      <element name="params" maxOccurs="1" minOccurs="1"> 
       <complexType> 
        <sequence> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="pName" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="pLo" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
        </sequence> 
        <attribute name="name" type="string" 
         default="firstPointDesc" /> 
       </complexType> 
      </element> 
      <element name="params" maxOccurs="1" minOccurs="1"> 
       <complexType> 
        <sequence> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="code" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
        </sequence> 
        <attribute name="name" type="string" 
         default="endPoint" /> 
       </complexType> 
      </element> 
      <element name="params" maxOccurs="1" minOccurs="1"> 
       <complexType> 
        <sequence> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="pName" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="pLo" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
        </sequence> 
        <attribute name="name" type="string" 
         default="endPointDesc" /> 
       </complexType> 
      </element> 
      <element name="param" maxOccurs="1" minOccurs="1"> 
       <complexType> 
        <sequence> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="temperature" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="humidity" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
         <element name="param" maxOccurs="1" 
          minOccurs="1"> 
          <complexType> 
           <simpleContent> 
            <extension base="string"> 
             <attribute name="name" 
              type="string" default="pressure" /> 
            </extension> 
           </simpleContent> 
          </complexType> 
         </element> 
        </sequence> 
        <attribute name="name" type="string" 
         default="bunch" /> 
       </complexType> 
      </element> 
.... 

,但沒有成功:Multiple elements with name 'param', with different types, appear in the model group.報道蝕。

任何人都可以提供這個或類似結構的描述的有效例子xsd? 我與wsdl模式和服務完全不同。

非常感謝。

回答

1

XML詞彙表的設計者似乎一直致力於使用普通的XML工具使XML無法驗證;他們可能已經成功了。爲了掩飾他們邪惡的計劃,最好的辦法可能是將他們的XML映射成同構的,但更容易驗證的XML(例如,使這些屬性值成爲元素名稱),或者查看XSD 1.1斷言並處理XPath 2.0技能。

相關問題