Re: [xml] RelaxNG bug?



2010/1/20 Elvis Stansvik <elvstone gmail com>:
2010/1/19 Daniel Veillard <veillard redhat com>:
On Fri, Jan 15, 2010 at 05:12:18PM +0100, Elvis Stansvik wrote:
Hello libxml2 folks,

The following minimal example validates with Jing but not libxml2 (git
version from today):

test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<a b="0%"/>

schema.rng:
<?xml version="1.0" encoding="UTF-8"?>
<grammar
  xmlns="http://relaxng.org/ns/structure/1.0";
  datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes";>

  <start>
    <element name="a">
      <attribute name="b">
        <list>
          <choice>
            <ref name="percent"/>
            <value>super</value>
            <value>sub</value>
          </choice>
          <optional>
            <ref name="percent"/>
          </optional>
        </list>
      </attribute>
    </element>
  </start>

  <define name="percent">
    <data type="string">
      <param name="pattern">-?([0-9]+(\.[0-9]*)?|\.[0-9]+)%</param>
    </data>
  </define>

</grammar>

[astan pyret test]$ xmllint --version
xmllint: using libxml version 20706-GITv2.7.6-8-g7946137
   compiled with: Threads Tree Output Push Reader Patterns Writer
SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer
XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas
Schematron Modules Debug Zlib
[astan pyret test]$ xmllint --relaxng schema.rng test.xml
<?xml version="1.0" encoding="UTF-8"?>
<a b="0%"/>
Unimplemented block at relaxng.c:8948
test.xml:2: element a: Relax-NG validity error : Element a failed to
validate attributes
test.xml fails to validate

It validates if I remove the entire <optional> from the <list>.

Any ideas? The code at relaxng.c:8948 indicates that this is a TODO.
Is that true or is this a real bug and the validator has been put into
an inconsistent state?

 Hum, yes I guess it's a bug in libvirt as the given define type seems
not supported there, that construct seems very unusual, since nobody
stepped on it ... until now !

libvirt? I guess you meant libxml2 ;)

Yes, the construct may be unusual. I bumped into it though when trying
to validate an OpenDocument document in strict mode using the RelaxNG
schemas from OASIS.

http://www.oasis-open.org/committees/download.php/12569/OpenDocument-schema-v1.0-os.rng
(On line 13737)

(Note that you have to validate using
http://www.oasis-open.org/committees/download.php/12569/OpenDocument-strict-schema-v1.0-os.rng,
which includes the aforementioned file and sets it up for strict
validation, for that line to kick in.)

What do you say, do you think it's a hard thing to fix?

This guy (Jos) in the KOffice project is working on an automated test
harness for our conversion of other office formats to OpenDocument
where he first converts to OpenDocument and then run a validation on
the resulting document. This is how the problem was found.

I'd just like to note that it's not until now that I see that Jos van
den Oever, around the same time as my initial post, made his own post
to the list about this problem with the specific document that
triggered the problem for him.

I believe my narrowed down test case illustrates the same problem though.

Feel free to continue the discussion in his thread and ignore mine,
we're in the same boat ;)

BTW I did some half-hearted attempt at fixing it by adding a case for
XML_RELAXNG_OPTIONAL to that switch by copying the one that is used
for XML_RELAXNG_GROUP, but it only got me half-way to a fix and I
think I'm too unfamiliar with the code to find a proper one.

Elvis


It would be nice if the OpenDocument schemas were supported by libxml2
since libxml2 is so much more widely available (and leaner!) than
Jing.

Regards,
Elvis


Daniel

--
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/





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