我正在尝试使用XML::Validator::Schema针对架构验证xml文件 但它给了我这个错误:
Found unexpected <Submission> inside <<<<ROOT>>>>. This is not a valid child element. [Ln: 2, Col:119]
注意:<Submission>
是<xml version="1.0" encoding="UTF-8"?>
我无法弄清楚它的含义。
感谢任何帮助。
XML是:
<?xml version="1.0" encoding="utf-8"?>
<Submission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="layout-topologie.xsd">
<Return>
<NR4>
<NR4Slip>
<RCPNT_NM>
<snm>SYMPSOM</snm>
<gvn_nm>HOMER</gvn_nm>
<init>A</init>
</RCPNT_NM>
<SEC_RCPNT_NM></SEC_RCPNT_NM>
<RCPNT_ADDR>
<addr_l1_txt>C/O ABC A/C 555 6666</addr_l1_txt>
<addr_l2_txt>9999 - 88 STREET</addr_l2_txt>
<cntry_cd>CAN</cntry_cd>
<fgn_pstl_cd>T4S1M5</fgn_pstl_cd>
</RCPNT_ADDR>
<fssn_nbr>607-448-900</fssn_nbr>
<nr_acct_nbr>NRY454080</nr_acct_nbr>
<rcpnt_tcd>01</rcpnt_tcd>
<payr_nbr>100000</payr_nbr>
<inc_1_tcd>11</inc_1_tcd>
<crcy_1_cd>CAD</crcy_1_cd>
<tx_xmpt_1_cd>AB</tx_xmpt_1_cd>
<inc_2_tcd>02</inc_2_tcd>
<crcy_2_cd>CAD</crcy_2_cd>
<tx_xmpt_2_cd>PQ</tx_xmpt_2_cd>
<NR4_AMT>
<gro_1_incamt>1.1</gro_1_incamt>
<nr_tx_1_amt>0.00</nr_tx_1_amt>
<gro_2_incamt>90000000</gro_2_incamt>
<nr_tx_2_amt>0.00</nr_tx_2_amt>
</NR4_AMT>
<rpt_tcd>O</rpt_tcd>
</NR4Slip>
<NR4Slip>
<RCPNT_NM>
<snm>CARTMAN</snm>
<gvn_nm>ERIC</gvn_nm>
</RCPNT_NM>
<SEC_RCPNT_NM>
<sec_snm>SYMPSON</sec_snm>
<sec_gvn_nm>BART</sec_gvn_nm>
</SEC_RCPNT_NM>
<RCPNT_ADDR>
<addr_l1_txt>C/O DEFG A/C 555 2222</addr_l1_txt>
<addr_l2_txt>9999 - 88 STREET</addr_l2_txt>
<cntry_cd>CAN</cntry_cd>
<fgn_pstl_cd>T4S1M5</fgn_pstl_cd>
</RCPNT_ADDR>
<fssn_nbr>607-448-901</fssn_nbr>
<nr_acct_nbr>NRY454080</nr_acct_nbr>
<rcpnt_tcd>01</rcpnt_tcd>
<payr_nbr>200000</payr_nbr>
<inc_1_tcd>11</inc_1_tcd>
<crcy_1_cd>USD</crcy_1_cd>
<tx_xmpt_1_cd>BC</tx_xmpt_1_cd>
<inc_2_tcd>02</inc_2_tcd>
<crcy_2_cd>USD</crcy_2_cd>
<tx_xmpt_2_cd>QR</tx_xmpt_2_cd>
<NR4_AMT>
<gro_1_incamt>20.01</gro_1_incamt>
<nr_tx_1_amt>10</nr_tx_1_amt>
<gro_2_incamt>8000000</gro_2_incamt>
<nr_tx_2_amt>0.1</nr_tx_2_amt>
</NR4_AMT>
<rpt_tcd>O</rpt_tcd>
</NR4Slip>
<NR4Summary>
<PAYR_NM>
<l1_nm>THE BANK OF NOVA SCOTIA</l1_nm>
</PAYR_NM>
<PAYR_ADDR>
<addr_l1_txt>HR SHARED SERVICES PENSION DEPT.</addr_l1_txt>
<addr_l2_txt>7TH FLOOR, 888 BIRCHMOUNT ROAD</addr_l2_txt>
</PAYR_ADDR>
<tx_yr>2007</tx_yr>
<slp_cnt>10</slp_cnt>
</NR4Summary>
</NR4>
</Return>
</Submission>
XSD是:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- @@@@ Definition of NR4 ComplexTypes @@@@ 2008/sept/03 Version# 2.8 -->
<xsd:complexType name="NR4SlipType">
<xsd:all>
<xsd:element name="RCPNT_NM" type="NameType" minOccurs="0"/>
<xsd:element name="SEC_RCPNT_NM" type="NameType_2" minOccurs="0"/>
<xsd:element name="ENTPRS_NM" type="NR4_Line2Type" minOccurs="0"/>
<xsd:element name="RCPNT_ADDR" type="NR4ForeignAddressType" minOccurs="0"/>
<xsd:element name="tx_cntry_cd" type="char3Type"/>
<xsd:element name="fssn_nbr" type="char20Type"/>
<xsd:element name="nr_acct_nbr" type="nrType"/>
<xsd:element name="rcpnt_tcd" type="indicator1-5Type"/>
<xsd:element name="payr_nbr" type="char20Type" minOccurs="0"/>
<xsd:element name="inc_1_tcd" type="numeric2Type" minOccurs="0"/>
<xsd:element name="crcy_1_cd" type="char3Type" minOccurs="0"/>
<xsd:element name="NR4_AMT" type="NR4AmountType" minOccurs="0"/>
<xsd:element name="tx_xmpt_1_cd" type="char1Type" minOccurs="0"/>
<xsd:element name="inc_2_tcd" type="numeric2Type" minOccurs="0"/>
<xsd:element name="crcy_2_cd" type="char3Type" minOccurs="0"/>
<xsd:element name="tx_xmpt_2_cd" type="char1Type" minOccurs="0"/>
<xsd:element name="rpt_tcd" type="slipDataType"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="NR4AmountType">
<xsd:all>
<xsd:element name="gro_1_incamt" type="decimal11Type" minOccurs="0"/>
<xsd:element name="nr_tx_1_amt" type="decimal11Type" minOccurs="0"/>
<xsd:element name="gro_2_incamt" type="decimal11Type" minOccurs="0"/>
<xsd:element name="nr_tx_2_amt" type="decimal11Type" minOccurs="0"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="NR4SummaryType">
<xsd:all>
<xsd:element name="nr_acct_nbr" type="nrType"/>
<xsd:element name="PAYR_NM" type="Line3Type"/>
<xsd:element name="PAYR_ADDR" type="NR4CanadaAddressType" minOccurs="0"/>
<xsd:element name="CNTC" type="ContactType2"/>
<xsd:element name="tx_yr" type="yearType"/>
<xsd:element name="slp_cnt" type="int7Type"/>
<xsd:element name="rmt_tcd" type="indicator1-2Type" minOccurs="0"/>
<xsd:element name="rpt_tcd" type="otherDataType"/>
<xsd:element name="NR4_TAMT" type="NR4TotalsType" minOccurs="0"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="NR4TotalsType">
<xsd:all>
<xsd:element name="tot_gro_1_incamt" type="decimal13Type" minOccurs="0"/>
<xsd:element name="tot_nr_tx_1_amt" type="decimal13Type" minOccurs="0"/>
<xsd:element name="tot_gro_2_incamt" type="decimal13Type" minOccurs="0"/>
<xsd:element name="tot_nr_tx_2_amt" type="decimal13Type" minOccurs="0"/>
<xsd:element name="tot_nrpt_incamt" type="decimal13Type" minOccurs="0"/>
<xsd:element name="tot_nr_nrpt_tx_amt" type="decimal13Type" minOccurs="0"/>
</xsd:all>
<xsd:attribute name="tot_incamt" type="xsd:string"/>
<xsd:attribute name="tot_tx_wthld" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
答案 0 :(得分:2)
您已定义了几种类型,但尚未定义任何元素(除了那些定义为已定义的类型的子组件的元素)。 <Submission>
不仅没有定义,<Return>
(它的直接子元素)也不是<NR4>
,<NR4Slip>
等等。
您需要一系列<xsd:element>
块来将您定义的类型映射到实际元素/标记。 (以及<Return>
和<NS4>
的声明,但由于这些声明似乎只出现在<Submission>
中,因此您可能只想将它们声明为{{{}声明的一部分。 1}}。)
以下是使用现有类型的<Submission>
声明,但是在线声明其他元素。这是一个完全没有经过测试的,我在公共无线网络上打字,在度假时没有我的ORA的“XML Schema”副本:
<Submission>
这不会对您可以拥有的<xsd:element name="Submission" nillable="false">
<xsd:complexType>
<xsd:sequence maxOccurs="1" minOccurs="1">
<xsd:element name="Return">
<xsd:complexType>
<xsd:sequence maxOccurs="1" minOccurs="1">
<xsd:element name="NS4">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="NR4Slip" type="NR4SlipType" />
<xsd:element name="NR4Summary" type="NR4SummaryType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
或<NR4Slip>
块的数量产生任何限制;您可能希望在最内层<NR4Summary>
标记上使用minOccurs
和/或maxOccurs
属性进行设置。内联声明还绕过实际将<xsd:element>
或NR4SlipType
映射到元素。
答案 1 :(得分:1)
您的xsd中似乎没有提交元素。 我也没有看到返回元素。 你想定义它。
另一方面,保罗,谢谢你让我在第一份工作中被雇用并带我飞行。