【问题标题】:XML: .xsd: Error: The markup in the document following the root element must be well-formedXML:.xsd:错误:文档中根元素之后的标记必须格式正确
【发布时间】:2017-03-01 08:39:02
【问题描述】:

我指的是this video 了解架构。

我做了和那里解释的一样的事情:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://www.telusko.com/AlienSchema"
xmlns:tns="http://www.telusko.com/AlienSchema" 
elementFormDefault="qualified"></schema>

<complexType name="alienstype">
<sequence>
    <element name="alien" type="tns:alientype"></element>
</sequence>
</complexType>

<complexType name="alientype">
<sequence>
    <element name="name" type="string"></element>
    <element name="salary" type="integer"></element>
</sequence>
<attribute name="aid" type="ID" use=required""></attribute>
</complexType>

但我得到的错误是:

描述资源路径位置类型 文档中根元素之后的标记必须格式正确。 AlienSchema.xsd /XMLExamples 第 7 行 XML 架构问题

谁能告诉我,我在哪里做错了,为什么我会收到这个错误。提前致谢。

【问题讨论】:

  • 您需要写一个完整的问题,并在其中提供所有需要的信息,以便他人理解。视频没有帮助

标签: xml xsd schema


【解决方案1】:

您的 XML/XSD 文件中有两个错误:

  • 您在开头关闭了 &lt;schema ...&gt; 标记,导致文件格式不正确
  • 您的属性&lt;attribute name="aid" type="ID" use=required""&gt;&lt;/attribute&gt; 未正确定义其值use。应该改为use="required"

所以一个正确的文件应该是这样的:

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.telusko.com/AlienSchema" targetNamespace="http://www.telusko.com/AlienSchema" elementFormDefault="qualified">
    <complexType name="alienstype">
        <sequence>
            <element name="alien" type="tns:alientype"/>
        </sequence>
    </complexType>
    <complexType name="alientype">
        <sequence>
            <element name="name" type="string"/>
            <element name="salary" type="integer"/>
        </sequence>
        <attribute name="aid" type="ID" use="required"/>
    </complexType>
</schema>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多