[xml] Libxml not catching schema error
- From: "Yong Chen \(yongche\)" <chen cisco com>
- To: <xml gnome org>
- Subject: [xml] Libxml not catching schema error
- Date: Wed, 7 Feb 2007 15:18:50 -0800
Hi,
It seems libxml2 sometimes doesn't catch duplicate elements (under the
same parent element) when loading a schema. (Please see the simple
schema at the end).
xmlSchemaParserCtxtPtr parserCtxtPtr =
xmlSchemaNewParserCtxt("./sample.xsd"); -----line 1
xmlSchemaPtr schema = xmlSchemaParse(parserCtxtPtr); ------------>
line 2
Line 1 creates a parser context, and line 2 creates schema pointer.
For the schema below, there are two "ifid" elements in "interface_type"
complexType, I expect line 2 reports an error saying duplicate elements
defined, but instead, line 2 returns fine.
Thanks,
Yong Chen
Sample.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.my.com/test" targetNamespace="http://www.my.com/test"
elementFormDefault="qualified">
<xs:element name="show" type="show_type"/>
<xs:complexType name="show_type">
<xs:sequence>
<xs:element name="interface" minOccurs="1" type="interface_type"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="interface_type">
<xs:sequence>
<xs:element name="ifid" minOccurs="1" type="xs:string"/>
<xs:element name="ifid" minOccurs="1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]