Re: [xml] Libxml not catching schema error
- From: "Yong Chen \(yongche\)" <chen cisco com>
- To: "Yong Chen \(yongche\)" <chen cisco com>, <xml gnome org>
- Subject: Re: [xml] Libxml not catching schema error
- Date: Wed, 7 Feb 2007 15:30:15 -0800
One more info: it also doesn't catch duplicates in following (slightly
modified) sample file. Basically I inserted <xs:choice> as the parent of
those two "ifid" elements.
Thanks,
Yong Chen
<?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:choice>
<xs:element name="ifid" minOccurs="1" type="xs:string"/>
<xs:element name="ifid" minOccurs="1" type="xs:string"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:schema>
-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On
Behalf Of Yong Chen (yongche)
Sent: Wednesday, February 07, 2007 3:19 PM
To: xml gnome org
Subject: [xml] Libxml not catching schema error
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>
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org http://mail.gnome.org/mailman/listinfo/xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]