元素类型“xs:element”必须后跟属性规范“>”或“/>”

时间:2016-10-29 18:05:35

标签: xml xsd xsd-validation xml-validation

遇到XML Schema问题。它导致验证错误,我想知道问题是什么。

# -*- coding: utf-8 -*-
import ftplib 
from PyQt4 import QtGui, QtCore
import sys
import socket

app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()

List = ['one', 'two', 'free']

layer = QtGui.QVBoxLayout()
window.setLayout(layer)

def btn_clicked(btn):
    print 'button with text <%s> clicked' %(btn)

for i in List:
    button = QtGui.QPushButton(i)
    layer.addWidget(button)
    QtCore.QObject.connect(button, QtCore.SIGNAL('clicked()'),  btn_clicked(button.text())) # <--- the problem is here 

window.show()
sys.exit(app.exec_())

代码中的<?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> 有什么问题?缺少什么?由于第2行,它没有验证?

1 个答案:

答案 0 :(得分:2)

元素声明形成不良时会出现此错误。查找不属于元素声明的字符或关键字。

在您的情况下,/声明中有一个迷路description

更改

<xs:element type="xs:string" name="description"/ minOccurs="0" maxOccurs="unbounded"/>

<xs:element type="xs:string" name="description" minOccurs="0" maxOccurs="unbounded"/>

你将消除错误。