Skip Menu |
 

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 63655
Status: open
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: OPERA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.70
Fixed in: (no value)



Subject: Revalidation of dynamically-modified documents fails when using namespaces
Download (untitled) / with headers
text/plain 380b
Remember the bug with document revalidation? The one that was fixed in r785? Well, it seems it's still there if you use namespaces. See attached a patch against current trunk, adding a failing test case. To aid a bit when debugging, see the comments in both the test case document and the test XML schema: they contain a variant _without_ namespaces, which works as intended.
Subject: nstest.patch
Download nstest.patch
text/x-diff 4.1k
Index: test/relaxng/ns.rng =================================================================== --- test/relaxng/ns.rng (revision 0) +++ test/relaxng/ns.rng (revision 0) @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" --> +<grammar ns="http://xmlns.example.com/2007/test/datastore" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <!-- Document --> + <start> + <ref name="Datastore"/> + </start> + <define name="Datastore"> + <element name="datastore"> + <ref name="Data"/> + </element> + </define> + <define name="Data"> + <element name="data"> + <ref name="Active"/> + </element> + </define> + <!-- Structure elements --> + <define name="Active"> + <element name="active"> + <choice> + <interleave> + <zeroOrMore> + <ref name="Element"/> + </zeroOrMore> + </interleave> + <empty/> + </choice> + </element> + </define> + <define name="Element"> + <element name="element"> + <choice> + <ref name="Id"/> + <ref name="Did"/> + </choice> + <interleave> + <optional> + <ref name="Title"/> + </optional> + <optional> + <ref name="Payload"/> + </optional> + </interleave> + </element> + </define> + + <!-- Simple elements --> + <define name="Title"> + <element name="title"> + <data type="token"/> + </element> + </define> + <define name="Payload"> + <element name="payload"> + <data type="token"/> + </element> + </define> + <!-- Attributes --> + <define name="Id"> + <attribute name="id"> + <data type="ID"/> + </attribute> + </define> + <define name="Did"> + <attribute name="did"> + <data type="token"/> + </attribute> + </define> +</grammar> Index: t/25relaxng.t =================================================================== --- t/25relaxng.t (revision 824) +++ t/25relaxng.t (working copy) @@ -11,7 +11,7 @@ use XML::LibXML; if ( XML::LibXML::LIBXML_VERSION >= 20510 ) { - plan tests => 13; + plan tests => 17; } else { plan tests => 0; @@ -28,6 +28,7 @@ my $validfile = "test/relaxng/demo.xml"; my $invalidfile = "test/relaxng/invaliddemo.xml"; my $demo4 = "test/relaxng/demo4.rng"; +my $namespace = "test/relaxng/ns.rng"; print "# 1 parse schema from a file\n"; { @@ -113,5 +114,55 @@ } +print "# 6 re-validate a modified document\n"; +{ + my $parser = new XML::LibXML(); + + my $rngschema = XML::LibXML::RelaxNG->new(location => $namespace); + my $doc = $parser->parse_string(<<EOD); +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE datastore SYSTEM "//test/test/datastore" [ +<!ATTLIST element id ID #IMPLIED> +]> +<!-- datastore --> +<datastore xmlns="http://xmlns.example.com/2007/test/datastore"> + <data> + <active> + <element id="uuidtest1"> + <title>Ze element</title> + <payload>Ze element payload</payload> + </element> + </active> + </data> +</datastore> +EOD + eval{$rngschema->validate($doc);}; ok (!$@); + + my $node = $doc->createElement("element"); + + my $title = $doc->createElement("title"); + $title->appendText("Annoying tests are annoying"); + $node->appendChild($title); + + my $payload = $doc->createElement("payload"); + $payload->appendText("some payload"); + $node->appendChild($payload); + + $node->setAttribute('id', 'uuidIamAtestElement'); + + my ($active) = $doc->getElementsByTagName("active"); + eval{$rngschema->validate($doc);}; ok (!$@); + $active->appendChild($node); + + # If there's a bug in the dynamically-generated content, this test + # will always fail no matter what. Hence, we reparse the document + # and validate that (that always works) to make sure our + # modifications are really valid + my $reparsed_doc = $parser->parse_string($doc->toString); + eval{$rngschema->validate($reparsed_doc);}; ok (!$@); + + eval{$rngschema->validate($doc);}; ok (!$@); +} + } # Version >= 20510 test
Download (untitled) / with headers
text/plain 830b
Hi OPERA, On Mon Dec 06 04:50:41 2010, OPERA wrote: Show quoted text
> Remember the bug with document revalidation? The one that was fixed in > r785? Well, it seems it's still there if you use namespaces. > > See attached a patch against current trunk, adding a failing test case. > To aid a bit when debugging, see the comments in both the test case > document and the test XML schema: they contain a variant _without_ > namespaces, which works as intended.
thanks for the report. Attached is a new patch against the new conventions in the bitbucket repository, and it is maintained in the rt63655_revalidation branch. Hopefully, I'll take a look at this failure later on. Sorry it took us so long, but I've only started maintaining XML-LibXML less than two months ago, and the previous maintainer had been busy. Regards, -- Shlomi Fish
Subject: 63655-new.patch
Download 63655-new.patch
text/x-diff 4.5k
diff -r 0d5bc16a73ef -r f87e648f30ed MANIFEST --- a/MANIFEST Wed Jul 20 23:06:33 2011 +0300 +++ b/MANIFEST Wed Jul 20 23:21:14 2011 +0300 @@ -168,6 +168,7 @@ test/relaxng/demo3.rng test/relaxng/demo4.rng test/relaxng/invaliddemo.xml +test/relaxng/ns.rng test/relaxng/schema.rng test/schema/badschema.xsd test/schema/demo.xml diff -r 0d5bc16a73ef -r f87e648f30ed t/25relaxng.t --- a/t/25relaxng.t Wed Jul 20 23:06:33 2011 +0300 +++ b/t/25relaxng.t Wed Jul 20 23:21:14 2011 +0300 @@ -16,7 +16,7 @@ use XML::LibXML; if ( XML::LibXML::LIBXML_VERSION >= 20510 ) { - plan tests => 13; + plan tests => 17; } else { plan skip_all => 'Skip No RNG Support compiled'; @@ -32,6 +32,7 @@ my $validfile = "test/relaxng/demo.xml"; my $invalidfile = "test/relaxng/invaliddemo.xml"; my $demo4 = "test/relaxng/demo4.rng"; +my $namespace = "test/relaxng/ns.rng"; print "# 1 parse schema from a file\n"; { @@ -127,5 +128,63 @@ } +# 6 re-validate a modified document +{ + my $parser = new XML::LibXML(); + + my $rngschema = XML::LibXML::RelaxNG->new(location => $namespace); + my $doc = $parser->parse_string(<<EOD); +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE datastore SYSTEM "//test/test/datastore" [ +<!ATTLIST element id ID #IMPLIED> +]> +<!-- datastore --> +<datastore xmlns="http://xmlns.example.com/2007/test/datastore"> + <data> + <active> + <element id="uuidtest1"> + <title>Ze element</title> + <payload>Ze element payload</payload> + </element> + </active> + </data> +</datastore> +EOD + eval{$rngschema->validate($doc);}; + # TEST + ok (!$@); + + my $node = $doc->createElement("element"); + + my $title = $doc->createElement("title"); + $title->appendText("Annoying tests are annoying"); + $node->appendChild($title); + + my $payload = $doc->createElement("payload"); + $payload->appendText("some payload"); + $node->appendChild($payload); + + $node->setAttribute('id', 'uuidIamAtestElement'); + + my ($active) = $doc->getElementsByTagName("active"); + eval{$rngschema->validate($doc);}; + # TEST + ok (!$@); + $active->appendChild($node); + + # If there's a bug in the dynamically-generated content, this test + # will always fail no matter what. Hence, we reparse the document + # and validate that (that always works) to make sure our + # modifications are really valid + my $reparsed_doc = $parser->parse_string($doc->toString); + eval{$rngschema->validate($reparsed_doc);}; + # TEST + ok (!$@); + + eval{$rngschema->validate($doc);}; + # TEST + ok (!$@); +} + } # Version >= 20510 test diff -r 0d5bc16a73ef -r f87e648f30ed test/relaxng/ns.rng --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/relaxng/ns.rng Wed Jul 20 23:21:14 2011 +0300 @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" --> +<grammar ns="http://xmlns.example.com/2007/test/datastore" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <!-- Document --> + <start> + <ref name="Datastore"/> + </start> + <define name="Datastore"> + <element name="datastore"> + <ref name="Data"/> + </element> + </define> + <define name="Data"> + <element name="data"> + <ref name="Active"/> + </element> + </define> + <!-- Structure elements --> + <define name="Active"> + <element name="active"> + <choice> + <interleave> + <zeroOrMore> + <ref name="Element"/> + </zeroOrMore> + </interleave> + <empty/> + </choice> + </element> + </define> + <define name="Element"> + <element name="element"> + <choice> + <ref name="Id"/> + <ref name="Did"/> + </choice> + <interleave> + <optional> + <ref name="Title"/> + </optional> + <optional> + <ref name="Payload"/> + </optional> + </interleave> + </element> + </define> + + <!-- Simple elements --> + <define name="Title"> + <element name="title"> + <data type="token"/> + </element> + </define> + <define name="Payload"> + <element name="payload"> + <data type="token"/> + </element> + </define> + <!-- Attributes --> + <define name="Id"> + <attribute name="id"> + <data type="ID"/> + </attribute> + </define> + <define name="Did"> + <attribute name="did"> + <data type="token"/> + </attribute> + </define> +</grammar>


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.