XSD 元素命名空间验证失败

XSD element namespace validation failure

我在 Java 应用程序中工作,我需要在其中显示 XML 输出作为一次 GET REST URL 执行的结果。

我得到的错误是:

cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.example.org/xmlns/sapsaasconnection/SAPAriba/CATALOGCONTENT+facets_GET_Responses+286d4d67-dbb4-4187-ac9e-a9dd069c3035":Output}'. One of '{Output}' is expected.

我的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 的详细说明,请参见 What does elementFormDefault do in XSD?