XSD错误中的XML发现无效内容

Shijin TR

我正在尝试基于XSD架构定义创建XML文件,该架构定义在以下链接中找到

架构-http://xmlgw.companieshouse.gov.uk/v1-0/schema/forms/CompanyIncorporation-v2-6.xsd

我的XML如下

   <?xml version="1.0" encoding="UTF-8"?>
  <CompanyIncorporation xmlns="http://xmlgw.companieshouse.gov.uk" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk http://xmlgw.companieshouse.gov.uk/v2-1/schema/forms/CompanyIncorporation-v2-6.xsd">
    <CompanyType>BYSHR</CompanyType>
    <CountryOfIncorporation>EW</CountryOfIncorporation>
    <RegisteredOfficeAddress>
    <Premise>38</Premise>
    <Street>Vaughan Road</Street>
    <Thoroughfare>Pentwyn</Thoroughfare>
    <PostTown>Harrow</PostTown>
    <Country>GB-ENG</Country>
    <Postcode>HA1 4EE</Postcode>
    </RegisteredOfficeAddress>
    <Articles>BESPOKE</Articles>
    <RestrictedArticles>false</RestrictedArticles>
    <SameDay>false</SameDay>
    <SameName>false</SameName>
    <NameAuthorisation>false</NameAuthorisation>
    </CompanyIncorporation>

但是当我验证它时会产生一个错误,

Not valid.
Error - Line 15, 18: org.xml.sax.SAXParseException; lineNumber: 15; columnNumber: 18; 
cvc-complex-type.2.4.a: Invalid content was found starting with element 'SameDay'. One 
of '{"http://xmlgw.companieshouse.gov.uk":Appointment}' is expected.

演示

保罗·萨姆索塔

您似乎缺少一些要求。

文档类型CompanyIncorporationType只是sequence元素的一个。使用sequence,必须指定其中的所有元素,除非minOccurs设置为0。

schema元素xsd:sequence定义了封闭的元素集应按照给定的顺序并根据指定的最小和最大重复计数出现。(两者的默认值为1。)

由于错误发生在<SameDay>,请查看<xs:element name="RestrictedArticles">之间的xsd中定义的所有(相同级别)元素。<xs:element name="SameDay">

  • <xs:element name="Appointment" maxOccurs="unbounded">-必填

  • <xs:element name="StatementOfCapital" type="StatementOfCapitalType" minOccurs="0"/>-不需要

  • <xs:element name="Subscribers" type="SubscriberPersonType" minOccurs="0" maxOccurs="unbounded">-不需要

  • <xs:element name="Guarantors" type="GuarantorType" minOccurs="0" maxOccurs="unbounded">-不需要

  • <xs:element name="Authoriser">-必填

所以...

您缺少两个要素,<Appointment>并且<Authorizer>之前<SameDay>

也就是说,使用IDE(或某些xml工具)创建xml shema实现通常会有所帮助。例如,使用Eclipse,它将创建裸露的骨骼最小骨架以针对xsd进行验证。

这是由Eclipse创建的文件,该文件对xml进行验证具有最低要求

<?xml version="1.0" encoding="UTF-8"?>
<CompanyIncorporation ... >
    <CompanyType>PLC</CompanyType>
    <CountryOfIncorporation>EW</CountryOfIncorporation>
    <RegisteredOfficeAddress>RegisteredOfficeAddress</RegisteredOfficeAddress>
    <Appointment>
        <Authentication>Authentication</Authentication>
        <Authentication>Authentication</Authentication>
        <Authentication>Authentication</Authentication>
        <Director />
    </Appointment>
    <Authoriser>
        <Agent>
            <Person>Person</Person>
            <Authentication />
            <Authentication />
            <Authentication />
            <Address>Address</Address>
        </Agent>
    </Authoriser>
    <SameDay>true</SameDay>
</CompanyIncorporation>

更新

为了解释您在<Appointment>和中看到的元素<Authoriser>

<Appointment>

<xs:element name="Appointment" maxOccurs="unbounded">
    <xs:annotation>
        <xs:documentation>Proposed officers</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Authentication" type="PersonalAttributeType" minOccurs="3" maxOccurs="3"/>
            <xs:choice>
                <xs:element name="Director">
                    <xs:complexType>
                        <xs:complexContent>
                            <xs:extension base="DirectorAppointmentType"/>
                        </xs:complexContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="Secretary" type="SecretaryAppointmentType"/>
                <xs:element name="Member" type="MemberAppointmentType"/>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>
</xs:element>

你可以看到<Appointment>有一个sequence-<Authentication>正好三次,choice之间<Director><Secretary><Member>您将必须对xsd进行排序才能真正看到这些元素类型的要求

<Authoriser>

<xs:element name="Authoriser">
    <xs:complexType>
        <xs:choice>
            <xs:element name="Agent" type="AgentType">
            </xs:element>
            <xs:element name="Solicitor" type="AuthoriserType">
            </xs:element>
            <xs:element name="Member" type="AuthoriserType">
            </xs:element>
            <xs:element name="Subscribers">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="Subscriber" type="AuthoriserType" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:choice>
    </xs:complexType>
</xs:element>

你可以看到<Authoriser>,需要一个单一的任何一种选择<Agent><Member><Solicitor>,或<Subscriber>您将必须对xsd进行排序才能真正看到这些元素类型的要求

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

XSD错误中的XML错误内容无效

来自分类Dev

Spring Security XML错误-cvc-complex-type.2.4.a:发现无效的内容(从元素“ csrf”开始)

来自分类Dev

XSD错误:内容无效。预期的是(注释?)

来自分类Dev

发现XML无效的内容以元素开头。预期为“ {}”之一

来自分类Dev

如何“解决发现以元素开头的无效内容” Schematron错误?

来自分类Dev

XML .xsd无效元素

来自分类Dev

XML .xsd无效元素

来自分类Dev

发现内容以元素“ property”开头的内容无效

来自分类Dev

发现内容以元素“ property”开头的内容无效

来自分类Dev

Maven:发现无效的内容以元素“ plugin”开头

来自分类Dev

从元素开始发现无效的内容

来自分类Dev

发现无效的内容,以元素“ hc:html”开头

来自分类Dev

发现以元素“Generator”开头的无效内容

来自分类Dev

cvc-complex-type.2.4。在faces-config.xml中发现了以元素工厂开头的无效内容

来自分类Dev

使用XSD验证XML。错误:无效的架构或缺少名称空间

来自分类Dev

Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

来自分类Dev

'解组错误:cvc-complex-type.2.4.a:发现无效的内容,从元素'XXXXX'开始。预期为“ {XXXXX}”之一

来自分类Dev

Android SDK安装。错误:发现从元素'd:skin'开始的无效内容。目前预计没有子元素

来自分类Dev

Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

来自分类Dev

Excel发现不可读的内容错误

来自分类Dev

无效的NCName-XSD验证错误

来自分类Dev

Xml错误无效令牌

来自分类Dev

XML错误:无效字符

来自分类Dev

XML错误:无效字符

来自分类Dev

Xml错误无效令牌

来自分类Dev

Ajax:无效的XML错误

来自分类Dev

发现无效的内容以元素“ global-method-security”开头

来自分类Dev

HandlerInterceptorAdaptarer Spring-从元素'bean'开始发现无效内容

来自分类Dev

发现无效的内容以元素“ global-method-security”开头

Related 相关文章

  1. 1

    XSD错误中的XML错误内容无效

  2. 2

    Spring Security XML错误-cvc-complex-type.2.4.a:发现无效的内容(从元素“ csrf”开始)

  3. 3

    XSD错误:内容无效。预期的是(注释?)

  4. 4

    发现XML无效的内容以元素开头。预期为“ {}”之一

  5. 5

    如何“解决发现以元素开头的无效内容” Schematron错误?

  6. 6

    XML .xsd无效元素

  7. 7

    XML .xsd无效元素

  8. 8

    发现内容以元素“ property”开头的内容无效

  9. 9

    发现内容以元素“ property”开头的内容无效

  10. 10

    Maven:发现无效的内容以元素“ plugin”开头

  11. 11

    从元素开始发现无效的内容

  12. 12

    发现无效的内容,以元素“ hc:html”开头

  13. 13

    发现以元素“Generator”开头的无效内容

  14. 14

    cvc-complex-type.2.4。在faces-config.xml中发现了以元素工厂开头的无效内容

  15. 15

    使用XSD验证XML。错误:无效的架构或缺少名称空间

  16. 16

    Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

  17. 17

    '解组错误:cvc-complex-type.2.4.a:发现无效的内容,从元素'XXXXX'开始。预期为“ {XXXXX}”之一

  18. 18

    Android SDK安装。错误:发现从元素'd:skin'开始的无效内容。目前预计没有子元素

  19. 19

    Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

  20. 20

    Excel发现不可读的内容错误

  21. 21

    无效的NCName-XSD验证错误

  22. 22

    Xml错误无效令牌

  23. 23

    XML错误:无效字符

  24. 24

    XML错误:无效字符

  25. 25

    Xml错误无效令牌

  26. 26

    Ajax:无效的XML错误

  27. 27

    发现无效的内容以元素“ global-method-security”开头

  28. 28

    HandlerInterceptorAdaptarer Spring-从元素'bean'开始发现无效内容

  29. 29

    发现无效的内容以元素“ global-method-security”开头

热门标签

归档