【发布时间】:2010-04-15 03:41:34
【问题描述】:
我正在使用 Qt C++ 并正在读取 XML 文件中的数据。我想确保 XML 文件包含有效元素,所以我开始编写一个 XML Schema 来验证(Qt 不支持验证 DTD)。问题是,我不确定我的 Schema 本身是否有效,而且我似乎找不到真正的 XSD 验证器。我尝试使用http://www.w3.org/2001/03/webdata/xsv 的官方 w3c 验证器,但它给了我空白输出。有没有人知道一个像样的 XSD 验证器,或者可能愿意手动查看以下内容?
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="ballot">
<xs:complexType>
<xs:sequence>
<xs:element name="races">
<xs:complexType>
<xs:element name="race" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="rtitle" minOccurs="1" maxOccurs="1" type="xs:string"/>
<xs:element name="candidates" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:element name="candidate" minOccurs="1" maxOccurs="10">
<xs:complexType>
<xs:element name="candname" minOccurs="1" maxOccurs="1" type="xs:string"/>
<xs:element name="candparty" minOccurs="1" maxOccurs="1" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
<xs:element name="propositions">
<xs:complexType>
<xs:element name="proposition" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:element name="ptitle" minOccurs="1" maxOccurs="1" type="xs:string"/>
<xs:element name="pdesc" minOccurs="1" maxOccurs="1" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
请告诉我你的想法,我很感激!
【问题讨论】: