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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
> Behalf Of Yong Chen (yongche)
> Sent: Wednesday, February 07, 2007 3:19 PM
> To: [email protected]
> 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/ 
> [email protected] http://mail.gnome.org/mailman/listinfo/xml
> 
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to