Skip Menu |

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

Report information
The Basics
Id: 39165
Status: new
Priority: 0/
Queue: Template-XML

People
Owner: Nobody in particular
Requestors: mbeasterfeld [...] allenpress.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.17
Fixed in: (no value)



Subject: namespaces break "starttag"
Can't locate object method "toString" via package "XML::LibXML::Namespace" at /usr/lib/perl5/vendor_perl/5.8.8/Template/Plugin/XML/LibXML.pm line 229. From LibXML.pm: sub starttag { my ($self) = @_; my $output = "<". $self->nodeName(); foreach my $attr ($self->attributes) { $output .= $attr->toString(); } $output .= ">"; return $output; } <article xmlns:xlink="http://www.w3.org/1999/xlink"> will fail because the 'attributes' method evaluates namespaces and attributes differently. Namespaces become XML::LibXML::Namespace objects which do not have the "toString" method. http://search.cpan.org/~pajas/XML-LibXML-1.66/lib/XML/LibXML/Node.pod "Because XML::LibXML does not implement namespace declarations and attributes the same way, it is required to test what kind of node is handled while accessing the functions result." Template-Toolkit-2.19 XML-LibXML-1.66 Template-XML-2.17 Perl 5.8.8 Gentoo Linux Example script: #!/usr/local/bin/perl -w use strict; use warnings; use Template; my $output; my $template = Template->new( { OUTPUT => \$output, }); my $xml = '<article xmlns:xlink="http://www.w3.org/1999/xlink"></article>'; $template->process( 'example.tt', {'xml' => $xml} ); print $output; Example template: [% VIEW example; BLOCK article; item.starttag; item.content(view); item.endtag; END; END; USE document = XML.LibXML(xml); TRY; document.present(example); CATCH; error; END; %]