Re: [xml] xml schema validation



Hi,

Kuperus, AgeJan wrote:
We recently upgraded from libxml2 2.6.7 to 2.6.17 and discovered that
the following xml, that was marked as valid in 2.6.7 is now marked as
invalid:

<wwwtest isn="103" xmlns="http://library.wur.nl/WebQuery/ns/wwwtest";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://library.wur.nl/WebQuery/ns/wwwtest
http://library.wur.nl/WebQuery/ns/wwwtest.xsd";>
        <elem>test</elem>
</wwwtest>

If we just create a prefix for it, it becomes valid again:

<x:wwwtest isn="103" xmlns:x="http://library.wur.nl/WebQuery/ns/wwwtest";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://library.wur.nl/WebQuery/ns/wwwtest
http://library.wur.nl/WebQuery/ns/wwwtest.xsd";>
        <elem>test</elem>
</x:wwwtest>

Can anybody tell me why the first form is invalid ?

Your schema has a elementFormDefault="unqualified" attribute, which
states that locally declared elements are in no namespace.
When you used the default namespace, <elem> was bound to that namespace
as  well, which was not correct according to your schema. When you
removed the default namespace and prefixed it, and explicitely set
<x:wwwtest> to be in that namespace but not <elem>. So your latter case
is the correct one.

Libxml2 2.6.7 has a schema implementation dated of 2004-01-24. This
scenario wasn't handled correctly a year ago.

Regards,

Kasimier





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