Skip to content

Commit 7f7783c

Browse files
author
Dominique Quatravaux
committed
Get the bar green again
Also tested by flipping line 244 of lib/XML/XPathScript.pm to our $XML_parser = 'XML::XPath'; * Add get_qualified_name() in all the XML parser adapters, and provide suitable implementations for all three APIs. (For B::XPath it is more of a shot in the dark - I don't suppose B opcodes have namespaces) * By default, pretty-print the opening and closing tags of a node in terms of their get_qualified_name() instead of their get_name()
1 parent ee215dd commit 7f7783c

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

lib/XML/XPathScript/Processor.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ sub translate_comment_node {
632632
sub start_tag {
633633
my( $self, $node, $name ) = @_;
634634

635-
$name ||= $self->get_node_name( $node ) or return;
635+
$name ||= $self->get_qualified_name( $node ) or return;
636636

637637
my $string = '<'.$name;
638638

@@ -653,7 +653,7 @@ sub start_tag {
653653

654654
sub end_tag {
655655
my $self = shift;
656-
if (my $name = $_[1] || $self->get_node_name( $_[0] ) ) {
656+
if (my $name = $_[1] || $self->get_qualified_name( $_[0] ) ) {
657657
return "</$name>";
658658
}
659659
return '';

lib/XML/XPathScript/Processor/B.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ sub to_string {
3131

3232
sub get_node_name { $_[1]->get_name }
3333

34+
sub get_qualified_name { $_[1]->get_name }
35+
3436
sub get_attributes {
3537
if ( $_[1]->can( 'get_attr_names' ) ) {
3638
return map { ( [ $_ => $_[1]->get_attr_value( $_ ) ] )

lib/XML/XPathScript/Processor/LibXML.pm

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ sub is_text_node {
1919
&& !$_[1]->isa('XML::LibXML::Comment');
2020
}
2121

22-
sub get_attributes { return $_[1]->attributes }
23-
sub get_text_content { return $_[1]->textContent }
24-
sub get_child_nodes { return $_[1]->childNodes }
25-
sub get_node_name { return $_[1]->localname }
26-
sub is_element_node { return $_[1]->isa( 'XML::LibXML::Element' ); }
27-
sub is_comment_node { return $_[1]->isa( 'XML::LibXML::Comment' ); }
28-
sub is_pi_node { return $_[1]->isa( 'XML::LibXML::PI' ); }
29-
sub is_nodelist { return $_[1]->isa( 'XML::LibXML::NodeList' ); }
22+
sub get_attributes { return $_[1]->attributes }
23+
sub get_text_content { return $_[1]->textContent }
24+
sub get_child_nodes { return $_[1]->childNodes }
25+
sub get_node_name { return $_[1]->localname }
26+
sub get_qualified_name { return $_[1]->nodeName }
27+
sub is_element_node { return $_[1]->isa( 'XML::LibXML::Element' ); }
28+
sub is_comment_node { return $_[1]->isa( 'XML::LibXML::Comment' ); }
29+
sub is_pi_node { return $_[1]->isa( 'XML::LibXML::PI' ); }
30+
sub is_nodelist { return $_[1]->isa( 'XML::LibXML::NodeList' ); }
3031

3132
sub get_attribute {
3233
return $_[1]->isa( 'XML::LibXML::Namespace' )

lib/XML/XPathScript/Processor/XPath.pm

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ sub get_namespace {
1212
return $_[1]->getNamespace( $prefix )->getExpanded();
1313
}
1414

15-
sub get_attributes { $_[1]->getAttributeNodes }
16-
sub get_text_content { $_[1]->getData }
17-
sub get_child_nodes { $_[1]->getChildNodes }
18-
sub get_node_name { $_[1]->getName && $_[1]->getLocalName }
19-
sub is_element_node { $_[1]->isa( 'XML::XPath::Node::Element' ); }
20-
sub is_text_node { $_[1]->isa( 'XML::XPath::Node::Text' ); }
21-
sub is_comment_node { $_[1]->isa( 'XML::XPath::Node::Comment' ); }
22-
sub is_pi_node { $_[1]->isa( "XML::XPath::Node::PI" ); }
23-
sub is_nodelist { $_[1]->isa( 'XML::XPath::NodeSet' ); }
24-
sub get_attribute { $_[1]->toString }
15+
sub get_attributes { $_[1]->getAttributeNodes }
16+
sub get_text_content { $_[1]->getData }
17+
sub get_child_nodes { $_[1]->getChildNodes }
18+
sub get_node_name { $_[1]->getName && $_[1]->getLocalName }
19+
sub get_qualified_name { $_[1]->getName }
20+
sub is_element_node { $_[1]->isa( 'XML::XPath::Node::Element' ); }
21+
sub is_text_node { $_[1]->isa( 'XML::XPath::Node::Text' ); }
22+
sub is_comment_node { $_[1]->isa( 'XML::XPath::Node::Comment' ); }
23+
sub is_pi_node { $_[1]->isa( "XML::XPath::Node::PI" ); }
24+
sub is_nodelist { $_[1]->isa( 'XML::XPath::NodeSet' ); }
25+
sub get_attribute { $_[1]->toString }
2526

2627
1;

0 commit comments

Comments
 (0)