XML 架构有问题。它导致验证错误,我想知道问题是什么。
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="row">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="abstract"/>
<xs:element type="xs:string" name="bibliography"/>
<xs:element type="xs:string" name="catno"/>
<xs:element type="xs:string" name="citation"/>
<xs:element type="xs:string" name="copyrightnotice"/>
<xs:element type="xs:string" name="description"/ minOccurs="0" maxOccurs="unbounded"/>
<xs:element type="xs:string" name="image"/>
<xs:element type="xs:string" name="metadatamodificationdate"/>
<xs:element type="xs:byte" name="pagetotal"/>
<xs:element type="xs:string" name="publisher"/>
<xs:element type="xs:string" name="publishercity"/>
<xs:element type="xs:string" name="publishercountry"/>
<xs:element type="xs:string" name="sponsor"/>
<xs:element type="xs:string" name="title"/>
<xs:element type="xs:string" name="titlelargerentity"/>
<xs:element type="xs:float" name="datemonth"/>
<xs:element type="xs:string" name="datetype"/>
<xs:element type="xs:float" name="dateyear"/>
<xs:element type="xs:string" name="era"/>
<xs:element type="xs:string" name="language" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="modid"/>
<xs:attribute type="xs:short" name="recordid"/>
</xs:complexType>
</xs:element>
</xs:schema>
代码中的xsd:schema
有什么问题?是不是少了什么?由于第 2 行,它未验证?
最佳答案
当元素声明的格式不正确时,就会出现此错误。查找不属于元素声明的字符或关键字。
就您而言,description
的声明中有一个杂散的 /
。
改变
<xs:element type="xs:string" name="description"/ minOccurs="0" maxOccurs="unbounded"/>
至
<xs:element type="xs:string" name="description" minOccurs="0" maxOccurs="unbounded"/>
这样您就可以消除错误。
关于xml - 元素类型 "xs:element"后面必须跟有属性规范 ">"或 "/>",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40322043/