[xml] xmllint reports non-determinist content model for schema



Hi,

This is my first post to this list. I searched the mailing list
archives and bugzilla, but couldn't find the exact issue I'm
confronted with (if I missed something, please point me to it).

I'm running into a "non-determinist" error with a schema even though I
don't think it's non-determinist (and both XSV and Xerces agree with
me; they too have no problem with the schema). I have reduced my
test-case to a simple example, see below.

Given the following schema:

        <?xml version="1.0" encoding="UTF-8"?>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
                <xs:element name="rules">
                        <xs:complexType>
                                <xs:sequence>
                                        <xs:element name="rule" minOccurs="0" maxOccurs="unbounded"/>
                                        <xs:sequence minOccurs="0" maxOccurs="1">
                                                <xs:element name="specialRule" minOccurs="1" maxOccurs="1"/>
                                                <xs:element name="rule" minOccurs="0" maxOccurs="unbounded"/>
                                        </xs:sequence>
                                </xs:sequence>
                        </xs:complexType>
                </xs:element>
        </xs:schema>

xmllint version 20708 complains with "Schemas parser error : local
complex type: The content model is not determinist."

The intention is to express that there can be any number of "rule"
elements, and there can be at most one "specialRule" (at any position
in between, before, or after the "rule"s). So the following xml's are
all valid:

        <?xml version="1.0" encoding="UTF-8"?>
        <rules>
                <rule/>
                <rule/>
                <specialRule/>
                <rule/>
        </rules>

        <?xml version="1.0" encoding="UTF-8"?>
        <rules>
                <specialRule/>
        </rules>

        <?xml version="1.0" encoding="UTF-8"?>
        <rules>
                <specialRule/>
                <rule/>
                <rule/>
                <rule/>
        </rules>

        <?xml version="1.0" encoding="UTF-8"?>
        <rules>
                <rule/>
                <rule/>
                <rule/>
        </rules>

But this one isn't (two specialRules):

        <?xml version="1.0" encoding="UTF-8"?>
        <rules>
                <specialRule/>
                <rule/>
                <rule/>
                <specialRule/>
                <rule/>
        </rules>



Is this a bug in libxml2?

And whether or not it's a bug: any workarounds? Can I write my schema
in another way to make xmllint succeed, and still express the same
constraints?

-- 
Johan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]