I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-12-17 16:36:25-08 by samuelferencik
warnings when XPath mixes elements and attributes
Hi, I am trying to select all nodes of all types:

$doc->findnodes("//node() | //@*");

This throws warnings like:

Use of uninitialized value in numeric eq (==) at XML/DOM/XPath.pm line 110.

The problem occurs because in XPath.pm, cmp() is called to compare an element with its own attribute. For example, if the document contains

<elm id="3" />

then the XPath above results in comparing the element "elm" with the attribute "elm/@id". For some reason, "elm" is not an ancestor of "elm/@id", so we proceed to compare their full ancestry, which results in the warning above.

Is this behaviour expected? Perhaps cmp() should behave somewhat nicer for this case.

Sam
Direct Responses: 11975 | Write a response
Posted on 2009-12-17 18:59:18-08 by mirod in response to 11973
Re: warnings when XPath mixes elements and attributes
It looks like a bug. I will investigate some more over the week-end. I do believe that indeed elm is not an ancestor of elm/@id, in the DOM attributes are attached to elements, but they are not their children. I think I will have to special case this. I will keep you posted. Thank you.
Direct Responses: 11978 | Write a response
Posted on 2009-12-18 06:59:49-08 by samuelferencik in response to 11975
Re: warnings when XPath mixes elements and attributes
Great, thanks.

For now, I just changed cmp() to do this:

while( $a_anc == $b_anc) { $a_anc= pop @a_pile or return -1; $b_anc= pop @b_pile or return 1; }
Direct Responses: Write a response