Re: [xml] libxml2 XML Schema validation limitation



Thanks very much for your reply, Martin. We are using version 2.6.22 and are
on a shared server where I can't get upgraded to the latest version to test
this for some time. I tried searching the mailing list archives for
"redefine" but am getting results that don't even have that word in it, as
well as a message saying "we're re-building the archive search indexes
(again)" so I don't know if that means search is totally broken.

I did some more testing on very simple files that use a redefine and get the
same error messages:

# Error 1: Unimplemented block at xmlschemas.c:10264 on line 0
# Error 1845: Element '{urn:cde.berkeley.edu:babl:book:1.00}Book': No
matching global declaration available for the validation root. in
/users/events/apache2/http-events/svn-checkout/htdocs/checkouts/allison-trun
k/htdocs/ on line 2

It obviously can't find the second file (book.xsd). They are in the same
directory, and I even tried putting an absolute path to book.xsd to no
avail. We are also able to get validation to work just fine on an XML file
conforming to just book.xsd.

Here are the files that won't validate in libxml2 (but validate fine with
Xerces):

Schema #1, bookRedefine.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:bk="urn:cde.berkeley.edu:babl:book:1.00"
targetNamespace="urn:cde.berkeley.edu:babl:book:1.00"
elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:redefine schemaLocation="book.xsd">
        <xs:complexType name="bookType">
                <xs:complexContent>
                    <xs:extension base="bk:bookType">
                        <xs:sequence>
                            <xs:element name="addedElement"
type="xs:string"></xs:element>
                        </xs:sequence>
                    </xs:extension>
                </xs:complexContent>
        </xs:complexType>
    </xs:redefine>
</xs:schema>

Schema #2, book.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:bk="urn:cde.berkeley.edu:babl:book:1.00"
targetNamespace="urn:cde.berkeley.edu:babl:book:1.00"
elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="book" type="bk:bookType"/>
    <xs:complexType name="bookType">
          <xs:sequence>
            <xs:element name="title" type="xs:string"/>
              <xs:element name="author" type="xs:string"/>  
          </xs:sequence>
    </xs:complexType>
</xs:schema>

XML Instance:
<?xml version="1.0" encoding="UTF-8"?>
<book xmlns="urn:cde.berkeley.edu:babl:book:1.00"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xsi:schemaLocation="urn:cde.berkeley.edu:babl:book:1.00
bookRedefine.xsd">
    <title>Great Book</title>
    <author>Joe Blow</author>
    <addedElement>added</addedElement>
</book>

Adapted version of command used to call the function:
$xml_file = file_get_contents($_FILES['uploadedXMLFile']['tmp_name']);
$xml = new DOMDocument();
$xml->loadXML($xml_file);

$xml->schemaValidate(bookRedefine.xsd)

It would REALLY help me if anyone could tell me when support for xs:redefine
might be added to libxml2's schema validation.

Thanks!
Allison 




-----Original Message-----
From: Martijn Faassen [mailto:faassen infrae com] 
Sent: Friday, October 06, 2006 2:19 AM
To: Allison Bloodworth
Cc: xml gnome org
Subject: Re: [xml] libxml2 XML Schema validation limitation

Hello,

Allison Bloodworth wrote:
We are using libxml2 in our PHP 5 application to do validation of an
imported XML document against an XML schema. I am finding that when I use
one XML Schema document which redefines some elements in a second XML
Schema
document, validation always fails.

E.g. UCBEvents.xsd redefines elements in Events_1.9.xsd:

      <xs:redefine schemaLocation="Events_1.9.xsd">

Does anyone know what the limitations of libxml2 are in terms of XML
Schema
validation? Is it unable to handle redefines?

While I know nothing much about the implementation or the error you 
report, you should check this same validation with the latest release of 
libxml2 if you haven't already. Various bugs in validation have been 
checked in newer versions, and the versions of libxml2 that ship with 
common linux distributions may not yet be up to date.

Regards,

Martijn




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