RE: [xml] Schema validation fails with global definitions



Hi Daniel,

These are complete samples of a schema and XML file. 
Validating this XML file using xmlSchemaValidateDoc() (Windows libxml 2.6.7)
shows the error 
"Element USER content check failure".

Thanks in advance

Israel Ganor

============================================================================
==
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified">
        <!-- Global (referenced) definitions -->
        <xs:attribute name="ACTION" type="xs:string"/>
        <xs:element name="EXPIRATION">
        <xs:complexType>
                <xs:all>
                        <xs:element name="DATE" type="xs:string"
minOccurs="0"/>
                </xs:all>
        </xs:complexType>
        </xs:element>
        <xs:element name="USER">
                <xs:complexType>
                        <xs:all>
                                <xs:element ref="EXPIRATION" minOccurs="0"/>
                        </xs:all>
                        <xs:attribute ref="ACTION" use="required"/>
                </xs:complexType>
        </xs:element>
        <!-- Root -->
        <xs:element name="BHUB-ADMIN">
                <xs:complexType>
                        <xs:choice maxOccurs="unbounded">
                                <xs:element ref="USER"/>
                        </xs:choice>
                </xs:complexType>
        </xs:element>
</xs:schema>

=========================================================================

<?xml version="1.0"?>
<BHUB-ADMIN xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="BrainSchema.xsd">
        <USER ACTION="add">
                <EXPIRATION>
                        <DATE>010104</DATE>
                </EXPIRATION>
        </USER>
</BHUB-ADMIN>
=========================================================================



-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com] 
Sent: Thursday, April 08, 2004 5:24 PM
To: Israel Ganor
Cc: 'xml gnome org'
Subject: Re: [xml] Schema validation fails with global definitions


On Thu, Apr 08, 2004 at 03:48:37PM +0200, Israel Ganor wrote:
Validating this simple file using xmlSchemaValidateDoc() (Windows 
libxml
2.6.7) always gives the error "Element USER content check failure":

<BHUB-ADMIN xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="BrainSchema.xsd">
    <USER ACTION="modify">
            <METHODS>5</METHODS>
    </USER>
</BHUB-ADMIN>

The schema fragment looks as follows:
--------------------------------------------------------
<xs:element name="BHUB-ADMIN">
    <xs:complexType>
            <xs:sequence>
                    <xs:element ref="USER"/>
            </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="METHODS" type="xs:byte"/>
<xs:element name="USER">
    <xs:complexType>
            <xs:sequence>
                    <xs:element ref="METHODS"/>
            </xs:sequence>
            <xs:attribute name="ACTION"/>
    </xs:complexType>
</xs:element>

Te error is resolved if I replace the global definition of USER 
(<xs:element
ref="USER"/>) by a local definition as follows:
[..]

Doesn't libxml2 support global elements?
This is a great problem for me since I have huge schemas 
with complex 
hierarchy, and many of the elements are common and referenced from 
several elements.

  I can't really make sense of a "schemas fragment". It seems 
to me this should work, but since you didn't provided a 
complete example 
I can't really reproduce the problem. Can you post the full xsd (or 
a reduced version of it rather).

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  
http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search 
engine http://rpmfind.net/


Attachment: BrainSchema.xsd
Description: Binary data



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