【发布时间】:2017-05-16 18:01:45
【问题描述】:
我正在为一个项目开发 XSD,这就是我所拥有的:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Elizabeth schema"
xmlns:elz="http://www.example.org/Elizabeth_schema" elementFormDefault="qualified">
<xs:element name ="year">
<xs:complexType mixed = "true">
<xs:sequence>
<xs:element name="entry">
<xs:complexType mixed ="true">
<xs:simpleContent>
<xs:attribute name ="when" type = "xs:string"/>
<xs:attribute name = "place" type = "xs:string"/>
<xs:element name = "items" type = "xs:string"/>
<xs:element name = "characters">
<xs:complexType>
<xs:attribute name ="character" type = "xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name = "eventscollection">
<xs:complexType>
<xs:attribute name = "type" type = "xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name ="entrytxt">
<xs:complexType>
<xs:any minOccurs = "0"/>
<xs:anyAttribute minOccurs="0"/>
</xs:complexType>
</xs:element>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我还没有将 xls 指向架构,因为我想让架构首先工作。我的 IDE 向我抛出了一个错误:
s4s-elt-invalid-content.1: '#AnonType_entryyear' 的内容是 无效的。元素“属性”无效、放错位置或也出现 经常。
第 11 行是我在元素“entry”下引入第一个属性的地方。我发现如果我删除第 10 行(“simpleContent”),我会得到相同的错误,但在第 13 行我在“条目”下引入了第一个元素。
我是这方面的初学者,我在互联网上做了一些刺激,但似乎无法弄清楚我的代码是怎么回事。有什么想法吗?
【问题讨论】:
标签: xml xsd xsd-validation xml-validation