First page Back Continue Last page Overview Graphics
XXX: Still Ugly
-
package XML::Twig::XPath::Attribute;
-
sub node_cmp
{ my( $a, $b)= @_;
-
# $a is always an attribute, but $b can be an att, elt or doc
-
if( UNIVERSAL::isa( $b, 'XML::Twig::XPath::Attribute'))
{ # 2 atts: compare their elts, then their name if on the same elt
return ($a->{elt}->cmp( $b->{elt}) ) | ($a->{name} cmp $b->{name});
}
-
elsif( UNIVERSAL::isa( $b, 'XML::Twig::XPath::Elt'))
{ # att <=> elt : compare the att->elt and the elt
# if att->elt is the elt (cmp returns 0) then 1 (elt before att)
return ($a->{elt}->cmp( $b) ) || 1 ;
}
-
elsif( UNIVERSAL::isa( $b, 'XML::Twig::XPath'))
{ # attribute <=> document, document is before att
return 1;
}
-
else { die "unknown node type ", ref( $b); }
}