Hi,
I have a schema (see at the end of email), I thought it was invalid,
since the "Naming" element in "group1" has the same name as the "Naming"
element in "group2", causing the content of element "Hello" to be
non-deterministic.
But I can create schema context without problem (no errors when calling
xmlSchemaNewParserCtxt, xmlSchemaSetParserErrors and xmlSchemaParse), I
can also validate the xml instance based on this schema and the instance
is OK. I'm using libxml2.6.20.
If I change the "minOccurs" from "1" to "0" for "group1", then I get
error when loading the schema as following:
./x.xsd:5: element complexType: Schemas parser error : local
complex type: The content model is not determinist.
But if instead, I only change the "minOccurs" from "1" to "0" for
"group2", then I don't get any error, schema seems to be fine.
Can someone tell me why this schema is valid?
Thanks,
Yong Chen
Schema file
========================================================================
========================
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Hello">
<xs:complexType>
<xs:sequence>
<xs:group ref="group1" minOccurs="1" maxOccurs="1"/>
<xs:group ref="group2" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="group1">
<xs:sequence>
<xs:element name="Naming">
<xs:complexType>
<xs:choice>
<xs:element name="g1_e1" type="xs:string"/>
<xs:element name="g1_e2" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:group name="group2">
<xs:sequence>
<xs:element name="Naming">
<xs:complexType>
<xs:choice>
<xs:element name="g2_e1" type="xs:string"/>
<xs:element name="g2_e2" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
</xs:schema>
=================End of Schema file
=======================================================
=================XML instance based on the schema
file=======================================
<?xml version="1.0"?>
<Hello xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Naming>
<g1_e1>I'm g1 e1</g1_e1>
</Naming>
<Naming>
<g2_e2>I'm g2 e2</g2_e2>
</Naming>
</Hello>
======================End of XML instance
====================================================
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml