2017-02-26 67 views
0

我指的是this video来理解模式。XML:.xsd:错误:根元素后面的文档中的标记必须格式良好

我也做了同样的解释有:

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

但我得到的错误是:

Description Resource Path Location Type The markup in the document following the root element must be well-formed. AlienSchema.xsd /XMLExamples line 7 XML Schema Problem

可能有人请让我知道,我哪里做错了,为什么我我得到这个错误。提前致谢。

+0

你需要写一个完整的问题,它提供了所有的订单所需的信息的人理解。一个视频是没有用的 –

回答

0

得到了错误,关闭模式标记应在年底

0

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

  • 你关在一开始<schema ...>标签正确导致文件不合格
  • 您的属性<attribute name="aid" type="ID" use=required""></attribute>未正确定义其值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>