簡體   English   中英

XSD 元素命名空間驗證失敗

[英]XSD element namespace validation failure

我在 Java 應用程序中工作,我需要在其中顯示 XML 輸出作為一個 GET REST URL 執行的結果。

我收到錯誤如下:

cvc-complex-type.2.4.a:發現以元素'{"http://www.example.org/xmlns/sapsaasconnection/SAPAriba/CATALOGCONTENT+facets_GET_Responses+286d4d67-dbb4-4187-ac9e-a9dd569c303"開頭的無效內容:輸出}'。 '{Output}' 之一是預期的。

我的 XSD 是:

<schema targetNamespace="http://www.example.org/xmlns/sapsaasconnection/SAPAriba/CATALOGCONTENT+facets_GET_Responses+286d4d67-dbb4-4187-ac9e-a9dd069c3035"
        xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://www.example.org/xmlns/sapsaasconnection/SAPAriba/CATALOGCONTENT+facets_GET_Responses+286d4d67-dbb4-4187-ac9e-a9dd069c3035"
        >
  <complexType name="facets_GET_Responses">
    <sequence>
      <element maxOccurs="1" minOccurs="0" name="Output" type="tns:FacetResponse"/>
    </sequence>
  </complexType>
  <element name="facets_GET_Responses" type="tns:facets_GET_Responses"/>
  <complexType name="MapStringToObject">
    <all>
      <element maxOccurs="1" minOccurs="0" name="count" type="integer"/>
      <element maxOccurs="1" minOccurs="0"
               name="ClassificationCode" type="string"/>
    </all>
  </complexType>
  <element name="MapStringToObject" type="tns:MapStringToObject"/>
  <complexType name="FacetResponse">
    <all>
      <element maxOccurs="1" minOccurs="0" name="contents" type="tns:contents"/>
      <element maxOccurs="1" minOccurs="0" name="offset" type="integer"/>
      <element maxOccurs="1" minOccurs="0" name="limit" type="integer"/>
      <element maxOccurs="1" minOccurs="0"
               name="totalElements" type="integer"/>
      <element maxOccurs="1" minOccurs="0"
               name="totalPages" type="integer"/>
      <element maxOccurs="1" minOccurs="0"
               name="firstPage" type="boolean"/>
      <element maxOccurs="1" minOccurs="0" name="lastPage" type="boolean"/>
    </all>
  </complexType>
  <element name="FacetResponse" type="tns:FacetResponse"/>
  <complexType name="contents">
    <sequence>
      <element maxOccurs="unbounded" minOccurs="0"
               name="items" type="tns:MapStringToObject"/>
    </sequence>
  </complexType>
</schema>

我的 XML 輸出是:

<ns0:facets_GET_Responses xmlns:ns0="http://www.example.org/xmlns/sapsaasconnection/SAPAriba/CATALOGCONTENT+facets_GET_Responses+286d4d67-dbb4-4187-ac9e-a9dd069c3035">
    <ns0:Output>
        <ns0:contents>
            <ns0:items>
                <ns0:count>42</ns0:count>
                <ns0:ClassificationCode>UNSPSC:1000030</ns0:ClassificationCode>
            </ns0:items>
        </ns0:contents>
        <ns0:limit>25</ns0:limit>
        <ns0:offset>0</ns0:offset>
        <ns0:totalElements>25</ns0:totalElements>
        <ns0:totalPages>1</ns0:totalPages>
        <ns0:firstPage>true</ns0:firstPage>
        <ns0:lastPage>true</ns0:lastPage>
    </ns0:Output>
</ns0:facets_GET_Responses>

我試圖以我的方式分析它,但沒有發現這里有什么問題。 任何人都可以按照 XSD 架構中的預期提供幫助嗎?

如果您希望更改 XSD,請將elementFormDefault="unqualified"添加到schema元素。

如果您希望更改 XML,請從除ns0:facets_GET_Responses之外的所有元素標記中刪除ns0名稱空間前綴。

請參閱elementFormDefault 在 XSD 中做什么? 有關elementFormDefault詳細說明。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM