Skip Menu |

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

Report information
The Basics
Id: 11772
Status: resolved
Priority: 0/
Queue: XML-DOM-XPath

People
Owner: MIROD [...] cpan.org
Requestors: yishayjobs [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.08
Fixed in: 0.09



Subject: XML::DOM::XPath restricts regular XML::XPath use
OS: WinXP perl -v: 5.8.4 XML-DOM-XPath-0.08 (with or without XML::XPath patch written by Mirod) ===== I have integrated XML::DOM::XPath into existing code, part of which already uses XML::XPath. I now find that expressions that used to give correct results throw an error. Example: =========== use XML::DOM::XPath; # if you delete this line it'll work use XML::XPath; my $xml = <<EOF; <?xml version="1.0" encoding="UTF-8"?> <school> <class> <student name="joe"/> <student/> </class> </school> EOF my $xp = XML::XPath->new($xml); my $exp = '/school/class/student/@name'; my $nodeSet = $xp->find($exp); print "number of nodes: ".$nodeSet->size()."\n"; ============== I get: ------ No such method cmp in XML::XPath::Node::ElementImpl at C:/Perl/site/lib/XML/DOM/XPath.pm line 28 ------ But if I delete the first line I get: -------- number of nodes: 1 -------- As expected.
Hi, It should be fixed in the development version at http://www.xmltwig.com/module/xml-dom-xpath/ Please check it, and if it fixes the problem for you I will upload it to CPAN. I have one question though: why do you want to do this? XML::XPath gives you the DOM API. In fact XML::XPath is really equivalent to XML::DOM + XML::DOM::XPath. So why not keep your XML::XPath code? -- Mirod
[MIROD - Mon Mar 7 05:22:43 2005]: Show quoted text
> Hi, > > It should be fixed in the development version at > http://www.xmltwig.com/module/xml-dom-xpath/ > > Please check it, and if it fixes the problem for you I will upload
it to Show quoted text
> CPAN.
Works fine. Cool. A bit off topic, a unit test still fails because of XML::XPath bug unless your XML::XPath patch is intalled. So instead of there just being a warning there's a failure. That may be the reason why the latest available version via ppm is 0.07. Show quoted text
> > I have one question though: why do you want to do this? XML::XPath
gives Show quoted text
> you the DOM API. In fact XML::XPath is really equivalent to XML::DOM
+ Show quoted text
> XML::DOM::XPath. So why not keep your XML::XPath code?
Basically I use XML::DOM::XPath for cutting and pasting XML subtrees. With XML::DOM::XPath I couldn't figure out how to alter the original document using the nodes found by the xpath expression. I wasn't aware that I could use XML::XPath and get the full DOM API... Thanks, Yishay
[guest - Mon Mar 7 08:49:41 2005]: Show quoted text
> Works fine. Cool. A bit off topic, a unit test still fails because of > XML::XPath bug unless your XML::XPath patch is intalled. So instead of > there just being a warning there's a failure. That may be the reason > why the latest available version via ppm is 0.07.
The reason ppm still has 0.07 is probably because 0.08 is quite recent (last week). Does the unit test really report a failure, or just a warning? It should warn for the bug in XML::XPath, but still report the test as OK. __ Mirod
Show quoted text
> > Does the unit test really report a failure, or just a warning? It
Yes, I attached nmake test output. My last reply was confused. I meant to say I wasn't getting (as far as I could tell) 'live' nodes via XML::XPath. That's why I started using XML::DOM::XPath.
Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib\lib', 'blib\arch')" t\1.t t\test_bugs.t t\test_xml_xpath_and_xml_dom_xpath.t t\xmlxpath_01basic.t t\xmlxpath_02descendant.t t\xmlxpath_03star.t t\xmlxpath_04pos.t t\xmlxpath_05attrib.t t\xmlxpath_06attrib_val.t t\xmlxpath_07count.t t\xmlxpath_08name.t t\xmlxpath_09a_string_length.t t\xmlxpath_09string_length.t t\xmlxpath_10pipe.t t\xmlxpath_12axisdescendant.t t\xmlxpath_13axisparent.t t\xmlxpath_14axisancestor.t t\xmlxpath_15axisfol_sib.t t\xmlxpath_16axisprec_sib.t t\xmlxpath_17axisfollowing.t t\xmlxpath_18axispreceding.t t\xmlxpath_19axisd_or_s.t t\xmlxpath_20axisa_or_s.t t\xmlxpath_21allnodes.t t\xmlxpath_22name_select.t t\xmlxpath_23func.t t\xmlxpath_24namespaces.t t\xmlxpath_25scope.t t\xmlxpath_26predicate.t t\xmlxpath_28ancestor2.t t\xmlxpath_29desc_with_predicate.t t\xmlxpath_30lang.t t\1...................................ok t\test_bugs........................... warning: the version of XPath you are using has a bug in the way it handles numeric comparisons. read the bug description: http://rt.cpan.org/NoAuth/Bug.html?id=6363 if an XML::XPath version with a fix for the bug is not yet available, you can get a patched version: http://xmltwig.com/xml-xpath-patched/ # Failed test (t\test_bugs.t at line 63) # got: 'e1e3e4' # expected: 'e1e3' # Looks like you failed 1 tests of 10. dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 8 Failed 1/10 tests, 90.00% okay t\test_xml_xpath_and_xml_dom_xpath....ok t\xmlxpath_01basic....................ok t\xmlxpath_02descendant...............ok t\xmlxpath_03star.....................ok t\xmlxpath_04pos......................ok t\xmlxpath_05attrib...................ok t\xmlxpath_06attrib_val...............ok t\xmlxpath_07count....................ok t\xmlxpath_08name.....................ok t\xmlxpath_09a_string_length..........ok t\xmlxpath_09string_length............ok t\xmlxpath_10pipe.....................ok t\xmlxpath_12axisdescendant...........ok t\xmlxpath_13axisparent...............ok t\xmlxpath_14axisancestor.............ok t\xmlxpath_15axisfol_sib..............ok t\xmlxpath_16axisprec_sib.............ok t\xmlxpath_17axisfollowing............ok t\xmlxpath_18axispreceding............ok t\xmlxpath_19axisd_or_s...............ok t\xmlxpath_20axisa_or_s...............ok t\xmlxpath_21allnodes.................ok t\xmlxpath_22name_select..............ok t\xmlxpath_23func.....................ok t\xmlxpath_24namespaces...............ok t\xmlxpath_25scope....................ok t\xmlxpath_26predicate................ok t\xmlxpath_28ancestor2................ok t\xmlxpath_29desc_with_predicate......ok t\xmlxpath_30lang.....................ok Failed 1/32 test scripts, 96.88% okay. 1/167 subtests failed, 99.40% okay. Failed Test Stat Wstat Total Fail Failed List of Failed ------------------------------------------------------------------------------- t\test_bugs.t 1 256 10 1 10.00% 8 NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0xff' Stop.
[guest - Tue Mar 8 03:01:26 2005]: Show quoted text
> > > > Does the unit test really report a failure, or just a warning? It
> > Yes, I attached nmake test output.
Duh! When I added test for the XML::XPath bug, I forgot to delete the original test. It's done now, and the new version is on it's way to CPAN (and it's on my site too). Show quoted text
> My last reply was confused. I meant to say I wasn't getting (as far as > I could tell) 'live' nodes via XML::XPath. That's why I started using > XML::DOM::XPath.
I understand, I thought for a while that this was the case, but if you look at the docs, http://search.cpan.org/dist/XML-XPath/XPath.pm forexample, you'll see DOM methods like createNode or setNodeText, XML::XPath::Node::Element has also appendChild... Thanks for your help __ Mirod