Re: LibXML, LibXSLT free(): invalid pointer error
by Joshua Santelli other posts by this author
Nov 21 2005 2:07PM messages near this date
view in the new Beta List Site
Re: LibXML, LibXSLT free(): invalid pointer error
|
Re: Perl-XML Digest, Vol 22, Issue 7
& XSLT The XML::LibXML::Node docs say that the node will be
imported first (see below) but I guess the docs could
be wrong. This appears to fix my test script so let
me know try this is the real code.
Thanks.
==================================================
$childnode = $node-> appendChild( $childnode );
The function will add the $childnode to the end of
$node's children. The function should fail, if the
new
childnode is allready a child of $node. This
function
differs from the DOM L2 specification, in the case,
if
the new node is not part of the document, the node
will
be imported first.
==================================================
--- rrathmann@[...].com wrote:
> In order to copy/move a node from one
> XML::LibXML::Document to another,
> you need to call XML::LibXML::Document->importNode(
> $node ) for copying
> or XML::LibXML::Document->adoptNode( $node ) for
> moving before you can
> attach it to the new document tree.
>
> For example, in your sample code you need to replace
>
> $root->appendChild( $results->getDocumentElement()
> );
>
> with something along the lines of
>
> my $import_node = $x->importNode(
> $results->getDocumentElement() );
> $root->appendChild( $import_node );
>
> HTH,
> Richard
>
> -----Original Message-----
> From: Joshua Santelli <santellij@[...].com>
> To: perl-xml@[...].com
> Sent: Mon, 21 Nov 2005 12:03:26 -0800 (PST)
> Subject: LibXML, LibXSLT free(): invalid pointer
> error
>
> We're getting an "invalid pointer" error (see
> below)
> from the following code. Is there something that I
> am
> doing wrong in either the XSLT or the perl code
> below?
>
>
> I'm trying to track down a problem in a larger
> system
> that we are developing and this small script appears
> to reproduce that problem.
>
> The LibXML, LibXSLT, perl and system versions are
> below.
>
> This is only a problem on Linux (spec below) and we
> are not able to reproduce this problem on Solaris 9.
>
> Thanks in advance.
>
> =======================================
> use XML::LibXSLT;
> use XML::LibXML;
>
> my $parser = XML::LibXML->new();
> my $xslt = XML::LibXSLT->new();
> my $xml = $ARGV[0];
> my $xsl = $ARGV[1];
>
> my $x = XML::LibXML::Document->new();
> my $root = $x->createElement("root");
> $x->setDocumentElement($root);
>
> my $source = $parser->parse_file($xml);
> my $style_doc = $parser->parse_file($xsl);
> my $stylesheet =
> $xslt->parse_stylesheet($style_doc);
> my $results = $stylesheet->transform($source);
>
> $root->appendChild( $results->getDocumentElement()
> );
>
> print $root->serialize();
> =======================================
> # ./libxslt.pl 1.xml toc.xsl
> <root><test version="2.0">
> <foo/>
> *** glibc detected *** /usr/bin/perl: free():
> invalid
> pointer: 0x08780829 ***
> ======= Backtrace: =========
> /lib/libc.so.6[0x84d424]
> /lib/libc.so.6(__libc_free+0x77)[0x84d95f]
>
/usr/lib/libxml2.so.2(xmlFreeNodeList+0x146)[0x3ae382e]
>
/usr/lib/libxml2.so.2(xmlFreeNodeList+0x89)[0x3ae3771]
>
/usr/lib/libxml2.so.2(xmlFreeNodeList+0x89)[0x3ae3771]
> /usr/lib/libxml2.so.2(xmlFreeDoc+0xdc)[0x3ae3e20]
> ... this goes on.
> =======================================
> <?xml version="1.0" encoding="UTF-8"?>
> <test version="2.0">
> <foo/>
> </test>
> =======================================
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> <xsl:copy-of select="current()" />
> </xsl:template>
> </xsl:stylesheet>
> ======================================
> RedHat FC4
> PERL v5.8.6 built for i386-linux-thread-multi
>
> installed the following from source:
> XML::LibXSLT::VERSION -> 1.58
> libxslt version ->1.1.15
> XML::LibXML::VERSION -> 1.58
> XML::LibXML::LIBXML_DOTTED_VERSION -> 2.6.22
>
>
>
> __________________________________
> Yahoo! FareChase: Search multiple travel sites in
> one click.
> http://farechase.yahoo.com
> _______________________________________________
> Perl-XML mailing list
> Perl-XML@[...].com
> To unsubscribe:
> http://listserv.ActiveState.com/mailman/mysubs
>
>
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Joshua Santelli
rrathmann
Joshua Santelli
|