Found an unexpected <View> inside <<< <ROOT> >>>. This is an invalid child

I am trying to validate an XML file against a schema using XML :: Validator :: Schema .
But it gives me this error:

Found unexpected <Submission> inside <<<<ROOT>>>>.  This is not a valid child element. [Ln: 2, Col:119]

      

Note: <Submission>

- this is the very first item I got after<xml version="1.0" encoding="UTF-8"?>

I can't figure out what this means.
Appreciate any help.

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>

      

-1


source share


2 answers


You have defined several types, but you have not defined any members (other than those defined as subcomponents of the types that you have defined). Not only is it <Submission>

not defined, nor <Return>

(which is its immediate child), nor any of <NR4>

, <NR4Slip>

etc.

You will need a series of blocks <xsd:element>

to map the types you have defined to the actual elements / tags. (Just like the declarations for <Return>

and <NS4>

, but since they only appear within the bounds <Submission>

, you can simply declare them inline as part of the declaration <Submission>

.)

Here's a bump in the declaration for <Submission>

, which uses your existing types, but declares other elements in the string. This is totally untested, top-of-the-head, printed on public wi-fi while on vacation without my copy of the ORA "XML Schema":



<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>

      

This does not give any limit on the number of blocks <NR4Slip>

or <NR4Summary>

that you can have; you can set this with attributes minOccurs

and / or maxOccurs

for the innermost tags <xsd:element>

. Inline ads also bypass actual display NR4SlipType

or NR4SummaryType

elements.

+2


source


It looks like you don't have a view element in the xsd. I also don't see the return item. You want to define it.



On the other hand, Paul, thanks for hiring me for my first job and picking me up.

+1


source







All Articles