2017-02-26 33 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> 
相關問題