我正在尝试用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文件进行轻微更改。我得到下面的错误
错误:元素“Return”:验证根目录没有匹配的全局声明
我认为问题在于你的
随后,我根据中包含的模式验证了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>
我调试了XSD集,最后发现了关键错误:
>
所以要么添加minOccurs="0"
属性到以下元素中的lemmcommontypes.xsd
<xsd:element ref="AddressLine1Text" minOccurs="0" /> <!-- Added by edit -->
这可能是不可能的,因为您无法更改XSD。
否则,将以下元素添加为XML的一部分
<PostSecondaryEducationalInstitutionMailingAddress>
<AddressLine1Text>WHATEVER!!!</AddressLine1Text> <!-- Added by edit -->
<CityName>ABBOTSFORD</CityName>
<ProvinceStateCode>BC</ProvinceStateCode>
<CountryCode>CAN</CountryCode>
<PostalZipCode>V2W3A9</PostalZipCode>
</PostSecondaryEducationalInstitutionMailingAddress>
另外,在lemmcommontypes中更改
到Decimal13AmountType
的定义。xsd
<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。
或者,如果无法执行此操作,请将值TotalEligibleTutionFeeAmunitum
从0
更改为0.00
,以使正则表达式匹配。
使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。
我创建了一个XML文件,但是当我试图对XSD进行验证时,我一直收到以下错误: 错误1845:元素{http://www.stormware.cz/schema/version_2/data.xsd}dataPack:验证根没有匹配的全局声明。 PHP5.4。7 libxml2.7。8. 我的职能: 我的XSD文件:www.stormware。cz/schema/version_2/data。xsd
我试图为以下XML文档创建一个XML模式。https://www.nationalbanken.dk/_vti_bin/DN/DataService.svc/CurrencyRatesHistoryXML?lang=en 然后,我在记事本上安装了XML工具插件,并尝试重新验证模式中的XML文档。 要验证的XML 但当我尝试验证模式时,我收到以下验证错误: 使用XML架构验证当前文件:错误:元素'{
使用名称空间时引用模式时的正确语法是什么? 问题 使用给定的架构创建XML文档。
我尝试使用http://www.freeformatter.com/xml-validator-xsd.html但由于上面的错误,它失败了。我发现了许多相同的问题,但没有一个答案对我有帮助。请帮助,正确的XML/XSD是什么? 我的XML:(只有最小的一个) 我的XSD:(只有最小的一个)
下面是XSD。 下面是xml文件。 当尝试使用http://www.utilities-online.info/xsdvalidation验证它时,我得到以下错误 第2行62:org.xml.sax.SAXParseException;行号:2;列号:62;CVC-ELT.1:找不到元素“Message”的声明。
问题内容: 我正在尝试配置NTLM身份验证,但收到错误: cvc-complex-type.2.4.c:匹配的通配符是严格的,但是找不到元素’http’的声明。 我阅读了很多类似错误的主题,但是找不到解决我问题的方法。 我的导致错误的security.xml文件是: 因为从3.X版本开始,Spring Security不再包含NTLM扩展,所以我从http://aloiscochard.blogs