cvc-elt.1.a: 找不到元素“xxx”的声明

5
我需要手写一个样本 XML 以匹配我的 XSD,但是我总是收到无效消息:cvc-elt.1.a: 找不到元素 'RS_WMS_GET_PO_DATA_v2.0' 的声明。 我的 XSD:
<?xml version="1.0" encoding="utf-16"?>
<schema xmlns:ns0="http://www.rossinc.com/" xmlns:msbtsdml="http://schemas.rossinc.com/BizTalk" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.rossinc.com/" xmlns="http://www.w3.org/2001/XMLSchema">
  <annotation>
    <appinfo>
      <msbtsdml:StoredProcedureName xmlns:msbtsdml="http://schemas.rossinc.com/BizTalk/DMLAdapter">RS_WMS_GET_PO_DATA</msbtsdml:StoredProcedureName>
      <msbtsdml:ResponseRootName xmlns:msbtsdml="http://schemas.rossinc.com/BizTalk/DMLAdapter">poData</msbtsdml:ResponseRootName>
    </appinfo>
  </annotation>
  <element name="RS_WMS_GET_PO_DATA_v2.0">
    <complexType>
      <sequence>
        <element minOccurs="1" maxOccurs="1" name="Parameters">
          <complexType>
            <sequence>
              <element default="0" name="ERROR_OCCURRED" type="string">
                <annotation>
                  <appinfo>
                    <msbtsdml:ParamDir xmlns:msbtsdml="http://schemas.microsoft.com/BizTalk/2003">In</msbtsdml:ParamDir>
                  </appinfo>
                </annotation>
              </element>
              <element default="1" name="XML_TAGS" type="int">
                <annotation>
                  <appinfo>
                    <msbtsdml:ParamDir xmlns:msbtsdml="http://schemas.microsoft.com/BizTalk/2003">In</msbtsdml:ParamDir>
                  </appinfo>
                </annotation>
              </element>
              <element default="0" name="NUM_ROWS" type="int">
                <annotation>
                  <appinfo>
                    <msbtsdml:ParamDir xmlns:msbtsdml="http://schemas.microsoft.com/BizTalk/2003">In</msbtsdml:ParamDir>
                  </appinfo>
                </annotation>
              </element>
            </sequence>
          </complexType>
        </element>
        <element name="RS_WMS_GET_PO_DATA">
          <complexType>
            <all minOccurs="1" maxOccurs="1">
              <element name="COMPANY_CODE" type="string" />
              <element name="DIVISION" type="string" />
              <element name="PO_NUMBER" type="string" />
              <element name="PO_WH_SEQUENCE" type="string" />
              <element name="ERP_ACTION_CODE" type="string" />
            </all>
          </complexType>
        </element>
        <element name="DMLAdapterConfig">
          <complexType>
            <sequence>
              <element name="EnvironmentId" type="string" />
            </sequence>
          </complexType>
        </element>
      </sequence>
    </complexType>
  </element>
</schema>

我的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<RS_WMS_GET_PO_DATA_v2.0>
    <Parameters>
        <ERROR_OCCURRED>0</ERROR_OCCURRED>
        <XML_TAGS>1</XML_TAGS>
        <NUM_ROWS>0</NUM_ROWS>
    </Parameters>
    <RS_WMS_GET_PO_DATA>
        <COMPANY_CODE></COMPANY_CODE>
        <DIVISION></DIVISION>
        <PO_NUMBER></PO_NUMBER>
        <PO_WH_SEQUENCE></PO_WH_SEQUENCE>
        <ERP_ACTION_CODE></ERP_ACTION_CODE>
    </RS_WMS_GET_PO_DATA>
    <DMLAdapterConfig>
        <EnvironmentId></EnvironmentId>
    </DMLAdapterConfig>
</RS_WMS_GET_PO_DATA_v2.0>

任何想法吗?
这是我正在使用的网站: http://www.corefiling.com/opensource/schemaValidate.html

可能是cvc-elt.1: Cannot find the declaration of element 'MyElement'的重复问题。 - crownjewel82
2个回答

4
<?xml version="1.0" encoding="UTF-8"?>
<ns0:RS_WMS_GET_PO_DATA_v2.0 xmlns:ns0="http://www.rossinc.com/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.rossinc.com/ One.xsd ">
<ns0:Parameters>
<ns0:ERROR_OCCURRED>0</ns0:ERROR_OCCURRED>
<ns0:XML_TAGS>1</ns0:XML_TAGS>
<ns0:NUM_ROWS>0</ns0:NUM_ROWS>
</ns0:Parameters>
<ns0:RS_WMS_GET_PO_DATA>
<ns0:COMPANY_CODE>ns0:COMPANY_CODE</ns0:COMPANY_CODE>
<ns0:DIVISION>ns0:DIVISION</ns0:DIVISION>
<ns0:PO_NUMBER>ns0:PO_NUMBER</ns0:PO_NUMBER>
<ns0:PO_WH_SEQUENCE>ns0:PO_WH_SEQUENCE</ns0:PO_WH_SEQUENCE>
<ns0:ERP_ACTION_CODE>ns0:ERP_ACTION_CODE</ns0:ERP_ACTION_CODE>
</ns0:RS_WMS_GET_PO_DATA>
<ns0:DMLAdapterConfig>
<ns0:EnvironmentId>ns0:EnvironmentId</ns0:EnvironmentId>
</ns0:DMLAdapterConfig>
</ns0:RS_WMS_GET_PO_DATA_v2.0>

由于您没有指定此XML文件使用的模式文件,我认为这会解决您的问题。


尝试再次运行,但失败了。错误:内容不允许在 prolog 中。 - vash_ace
你是如何验证它的。我根据你在问题中提供的XSD创建了一个XML,并使用Eclipse进行了创建。 - Madhusudan Joshi
请使用此链接在线验证XML与XSD:http://www.xmlvalidation.com/?L=0。勾选“根据外部XML模式验证”复选框,然后将XML文件复制到文本框中。单击“验证”按钮后,它会要求您将XSD复制为XML文件中引用的格式。 - Madhusudan Joshi
是的,它通过了,但是很奇怪吧?我的模式验证站点的方法与你的不同?@Joshi - vash_ace

4

我遇到了一个错误

cvc-elt.1.a: 找不到problem元素的声明!

我这样解决了它:

  1. Look for your XSD file, if it has a xmlns attribute, for instance:

    xmlns="http://yourcompany/blablabla/rootElementName"
    
  2. Look into your XML file, it must have an xmlns attribute if the XSD has defined one.

    <rootElement xmlns="http://company/xxxxxx/rootElementName">
    
  3. XML is case sensitive. Review your XML tags and compare them with the XSD tags.

Regards!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接