错误:元素"返回":没有匹配的全局声明可用于验证根



我正在尝试使用 xsd 文件验证 xml 文件以提交加拿大税务局的 T2202 税务单

下面是我的 xml 文件,可以稍微更改一下,以便使用 xsd 架构文件进行验证。

<?xml version="1.0" encoding="UTF-8"?>
<Return>
<T2202>
<T2202Slip>
<SlipReportTypeCode>O</SlipReportTypeCode>
<FilerAccountNumber>000000000RZ0000</FilerAccountNumber>
<PostSecondaryEducationalSchoolProgramName>Webdevelopment</PostSecondaryEducationalSchoolProgramName>
<PostSecondaryEducationalSchoolTypeCode>1</PostSecondaryEducationalSchoolTypeCode>
<FlyingSchoolClubCourseTypeCode>1</FlyingSchoolClubCourseTypeCode>
<StudentName>
<FamilyName>Jacob</FamilyName>
<GivenName>peter</GivenName>
<NameInitialText>k</NameInitialText>
</StudentName>
<SocialInsuranceNumber>000000000</SocialInsuranceNumber>
<StudentNumber>501058988</StudentNumber>
<StudentAddress>
<AddressLine1Text>202-2526 LAKEVIEW</AddressLine1Text>
<AddressLine2Text>CRES</AddressLine2Text>
<CityName>ABBOTSFORD</CityName>
<ProvinceStateCode>BC</ProvinceStateCode>
<CountryCode>CAN</CountryCode>
<PostalZipCode>V2W3A9</PostalZipCode>
</StudentAddress>
<SchoolSession>
<StartYearMonth>1901</StartYearMonth>
<EndYearMonth>1909</EndYearMonth>
<EligibleTuitionFeeAmount>153.64</EligibleTuitionFeeAmount>
<PartTimeStudentMonthCount>9</PartTimeStudentMonthCount>
<FullTimeStudentMonthCount>0</FullTimeStudentMonthCount>
</SchoolSession>
<TotalEligibleTuitionFeeAmount>0</TotalEligibleTuitionFeeAmount>
<TotalPartTimeStudentMonthCount>0</TotalPartTimeStudentMonthCount>
<TotalFullTimeStudentMonthCount>0</TotalFullTimeStudentMonthCount>
</T2202Slip>
<T2202Summary>
<FilerAccountNumber>000000000RZ0000</FilerAccountNumber>
<SummaryReportTypeCode>O</SummaryReportTypeCode>
<TaxationYear>2019</TaxationYear>
<TotalSlipCount>1</TotalSlipCount>
<PostSecondaryEducationalInstitutionName>
<NameLine1Text>CAREER COLLEGE</NameLine1Text>
</PostSecondaryEducationalInstitutionName>
<PostSecondaryEducationalInstitutionMailingAddress>
<CityName>ABBOTSFORD</CityName>
<ProvinceStateCode>BC</ProvinceStateCode>
<CountryCode>CAN</CountryCode>
<PostalZipCode>V2W3A9</PostalZipCode>
</PostSecondaryEducationalInstitutionMailingAddress>
<ContactInformation>
<ContactName>JOHN</ContactName>
<ContactAreaCode>604</ContactAreaCode>
<ContactPhoneNumber>720-4037</ContactPhoneNumber>
<ContactExtensionNumber>6789</ContactExtensionNumber>
</ContactInformation>
<TotalEligibleTuitionFeeAmount>153.64</TotalEligibleTuitionFeeAmount>
</T2202Summary>
</T2202>
</Return>

请在下面找到我的xsd架构文件,该文件来自政府网站。

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Description T2202 Return Complex and Element Types
Last updated    May 2019
Version#:   1.19 (version #.yy)
-->
<xsd:schema xmlns:sdt="http://www.cra-arc.gc.ca/xmlns/sdt/2-2-0" 
xmlns:ccms="http://www.cra-arc.gc.ca/xmlns/ccms/1-0-0" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.cra-arc.gc.ca/xmlns/sdt/2-2-0" schemaLocation="standarddatatypes.xsd"/>
<xsd:import namespace="http://www.cra-arc.gc.ca/xmlns/ccms/1-0-0" schemaLocation="cracommonstructures.xsd"/>
<xsd:include schemaLocation="lemmcommontypes.xsd"/>
<xsd:complexType name="T2202SlipType">
<xsd:sequence>
<xsd:element ref="SlipReportTypeCode"/>
<xsd:element name="FilerAccountNumber" type="BNRZType"/>
<xsd:element name="PostSecondaryEducationalSchoolProgramName" type="Length1to30TextType"/>
<!-- School type code:
1. University
2. College
3. Other education institution providing courses at a post-secondary school level
4. Certified by the Minister of Employment and Social Development Canada
5. Flying school or club
-->
<xsd:element name="PostSecondaryEducationalSchoolTypeCode" type="OneToFiveCodeType"/>
<!-- Flying school or club course type code. Must have a value if School type code is 5,
should be blank if school type code is 1-4. Valid values:
1. Private pilots license
2. Commercial pilots licence
3. Civil flying instructor rating
4. Helicopter category rating
5. Instrument rating
6. Other
-->
<xsd:element name="FlyingSchoolClubCourseTypeCode" type="OneToSixCodeType" minOccurs="0"/>
<xsd:element name="StudentName" type="IndividualNameType"/>
<xsd:element name="SocialInsuranceNumber" type="ccms:SINType"/>
<xsd:element name="StudentNumber" type="Length1to20TextType" minOccurs="0"/>
<xsd:element name="StudentAddress" type="RequiredLine1AddressType"/>
<xsd:element name="SchoolSession" type="SchoolSessionType" minOccurs="1" maxOccurs="4"/>
<xsd:element name="TotalEligibleTuitionFeeAmount" type="Decimal13AmountType" minOccurs="0"/>
<xsd:element name="TotalPartTimeStudentMonthCount" type="ZeroToTwelveCountType"/>
<xsd:element name="TotalFullTimeStudentMonthCount" type="ZeroToTwelveCountType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SchoolSessionType">
<xsd:all>
<xsd:element name="StartYearMonth" type="YYMMType"/>
<xsd:element name="EndYearMonth" type="YYMMType"/>
<xsd:element name="EligibleTuitionFeeAmount" type="Decimal11AmountType" minOccurs="0"/>
<xsd:element name="PartTimeStudentMonthCount" type="ZeroToTwelveCountType"/>
<xsd:element name="FullTimeStudentMonthCount" type="ZeroToTwelveCountType"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="T2202SummaryType">
<xsd:all>
<xsd:element name="FilerAccountNumber" type="BNRZType"/>
<xsd:element ref="SummaryReportTypeCode"/>
<xsd:element name="FilerAmendmentNote" type="Length1to1309TextType" minOccurs="0"/>
<xsd:element ref="TaxationYear"/>
<xsd:element ref="TotalSlipCount"/>
<xsd:element name="PostSecondaryEducationalInstitutionName" type="ThreeLinedLength30NameType"/>
<xsd:element name="PostSecondaryEducationalInstitutionMailingAddress" type="RequiredLine1AddressType"/>
<xsd:element name="ContactInformation" type="ContactType3" minOccurs="0"/>
<xsd:element name="TotalEligibleTuitionFeeAmount" type="Decimal15AmountType"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>

我需要验证 xml 文件。可以对 xml 文件进行细微更改。我收到以下错误

错误:元素"返回":没有匹配的全局声明可用于验证根

提前致谢

我调试了您的 XSD 集,并最终隔离了关键错误:

  1. 因此,请将minOccurs="0"属性添加到lemmcommontypes.xsd中的以下元素中,例如

    <xsd:element ref="AddressLine1Text" minOccurs="0" /> <!-- Added by edit -->
    

    这可能是不可能的,因为您无法更改 XSD。

  2. 或者,否则,将以下元素添加为 XML 的一部分

    <PostSecondaryEducationalInstitutionMailingAddress>
    <AddressLine1Text>WHATEVER!!!</AddressLine1Text>   <!-- Added by edit -->
    <CityName>ABBOTSFORD</CityName>
    <ProvinceStateCode>BC</ProvinceStateCode>
    <CountryCode>CAN</CountryCode>
    <PostalZipCode>V2W3A9</PostalZipCode>
    </PostSecondaryEducationalInstitutionMailingAddress>
    
  3. 此外,将lemmcommontypes.xsdDecimal13AmountType的定义更改为

    <xsd:simpleType name="Decimal13AmountType">
    <xsd:restriction base="sdt:AmountType">
    <xsd:totalDigits value="13"></xsd:totalDigits>
    <xsd:pattern value="[+]?d{0,11}(.d{2})?"/>
    <xsd:minInclusive value="0"/>
    </xsd:restriction>
    </xsd:simpleType>
    

    这可能是不可能的,因为您无法更改 XSD。

  4. 或者,如果无法执行此操作,请将TotalEligibleTuitionFeeAmount的值从0更改为0.00以使 RegEx 匹配。

以使 XML 与您的 XSD 集匹配。


在这两种情况下,您都必须将以下定义添加到上述 XSD 文件(从frms.xsd复制(:

<xsd:complexType name="T2202ReturnType">   <!-- From frms.xsd -->
<xsd:sequence>
<xsd:element name="T2202Slip" type="T2202SlipType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="T2202Summary" type="T2202SummaryType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ReturnChoiceType">  <!-- From frms.xsd -->
<xsd:choice>
<xsd:element name="T2202" type="T2202ReturnType" minOccurs="0"/>
</xsd:choice>
</xsd:complexType>
<xsd:element name="Return" type="ReturnChoiceType"/>

以使上述 XML 匹配。
现在,XML 应该进行验证。

我认为问题是您的<Return>应该按照 https://www.canada.ca/en/revenue-agency/services/e-services/filing-information-returns-electronically-t4-t5-other-types-returns-overview/upcoming-year-t619.html 包含在<Submission>中。

当我遵循它时,我的 xml 文件根据 https://www.canada.ca/content/dam/cra-arc/serv-info/eservices/xmlschm1-20-5.zip 中包含的架构进行了验证

我不必像当前接受的答案那样对XSD文件进行任何修改。

您提交给CRA的文件应如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<Submission xmlns:ccms="http://www.cra-arc.gc.ca/xmlns/ccms/1-0-0" 
xmlns:sdt="http://www.cra-arc.gc.ca/xmlns/sdt/2-2-0" 
xmlns:ols="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols/1-0-1" 
xmlns:ols1="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols1/1-0-1" 
xmlns:ols10="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols10/1-0-1" 
xmlns:ols100="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols100/1-0-1" 
xmlns:ols12="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols12/1-0-1" 
xmlns:ols125="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols125/1-0-1" 
xmlns:ols140="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols140/1-0-1" 
xmlns:ols141="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols141/1-0-1" 
xmlns:ols2="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols2/1-0-1" 
xmlns:ols5="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols5/1-0-1" 
xmlns:ols50="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols50/1-0-1" 
xmlns:ols52="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols52/1-0-1" 
xmlns:ols6="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols6/1-0-1" 
xmlns:ols8="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols8/1-0-1" 
xmlns:ols8-1="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols8-1/1-0-1" 
xmlns:ols9="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/ols9/1-0-1" 
xmlns:olsbr="http://www.cra-arc.gc.ca/enov/ol/interfaces/efile/partnership/olsbr/1-0-1" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="layout-topologie.xsd">
<T619>
<sbmt_ref_id>00000001</sbmt_ref_id>
<rpt_tcd>O</rpt_tcd>
<trnmtr_nbr>MM555555</trnmtr_nbr>
<trnmtr_tcd>1</trnmtr_tcd>
<summ_cnt>1</summ_cnt>
<lang_cd>E</lang_cd>
<TRNMTR_NM>
<l1_nm>CAREER COLLEGE</l1_nm>
</TRNMTR_NM>
<TRNMTR_ADDR>
<addr_l1_txt>Address of School</addr_l1_txt>
<cty_nm>ABBOTSFORD</cty_nm>
<prov_cd>BC</prov_cd>
<cntry_cd>CAN</cntry_cd>
<pstl_cd>V2W3A9</pstl_cd>
</TRNMTR_ADDR>
<CNTC>
<cntc_nm>JOHN LASTNAME</cntc_nm>
<cntc_area_cd>604</cntc_area_cd>
<cntc_phn_nbr>720-4037</cntc_phn_nbr>
<cntc_email_area>john@careercollege.com</cntc_email_area>
</CNTC>
</T619>
<Return>
Your return from above goes here
</Return>
</Submission>

最新更新