|
Re: More XML::LibXSLT registered functions woes: msg#00045lang.perl.xml
Elizabeth Mattijsen <liz@xxxxxxxxxx> writes: > Using the CVS versions of XML::LibXML and XML::LibXSLT (with Petr > Pajas latest patch), this script apparently does _not_ work as > expected: Yes, I knew there was more to fix :-( > ====================================================== > > use strict; > use warnings; > > use XML::LibXML (); > use XML::LibXSLT (); > > my $libxml = XML::LibXML->new; > my $libxslt = XML::LibXSLT->new; > > sub foo { $libxml->parse_string( qq{<foo zap="zoo">bar</foo>} ) }; > XML::LibXSLT->register_function( 'urn:bar','func','foo' ); > > my $dom = $libxml->parse_string( "<empty/>" ); > > my $xslt = $libxml->parse_string( <<'EOD' ); > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:foo="urn:bar" > exclude-result-prefixes="foo" >> > <xsl:output omit-xml-declaration="yes"/> > <xsl:template match="/"> > > <xsl:copy-of select="foo:func()"/> > > </xsl:template> > </xsl:stylesheet> > EOD > > my $stylesheet = $libxslt->parse_stylesheet( $xslt ); > > my $newdom = $stylesheet->transform( $dom ); > > print $stylesheet->output_string( $newdom ); # should print "<foo > zap="zoo">bar</foo>" > ====================================================== > > but instead of the expected string, it prints: > > XML::LibXML::Document=SCALAR(0xdeadbeef) We'll have to drag this through the debugger to see where the serialization is happening. However, changing it to sub foo { XML::LibXML::NodeList->new( $libxml->parse_string( qq{<foo zap="zoo">bar</foo>} )->getDocumentElement() ) }; (or similarly without getDocumentElement(), which segfaults immediately on my box) reveals some things that need fixing: with valgrind, there is a couple of bad xmlFreeNode calls catched but, but the script returns correct <foo zap="zoo">bar</foo>. Without valgrind, the bad xmlFreeNode calls take effect, memory is corrupted and the output is a mess like <h2B Řh2B="Hh2B"></h2B> or similar (lucky it doesn't segfault). -- Petr _______________________________________________ Perl-XML mailing list Perl-XML@xxxxxxxxxxxxxxxxxxxxxxxx To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | More XML::LibXSLT registered functions woes, Elizabeth Mattijsen |
|---|---|
| Next by Date: | Re: More XML::LibXSLT registered functions woes, Petr Pajas |
| Previous by Thread: | More XML::LibXSLT registered functions woes, Elizabeth Mattijsen |
| Next by Thread: | Re: More XML::LibXSLT registered functions woes, Petr Pajas |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |