[xml] Problem with XML::LibXSLT Extension function returning nodelist.



Hi.

I'm not sure if this is a Perl or libxml question.

I have an XSLT stylesheet which process multiple XML files.
I have added extension functions to lookup information (based on attributes in the XML) from a different, constant XML file and return a nodelist of additional information which is used in a for-each loop in the XSLT.

This all works fine in Windows XP.

But under Linux - using variuous versions of libxml/libxslt - I get a segmentation or memory fault error:
E.g.
Recoding from TM_OUT to CM_OUT
.*** glibc detected *** double free or corruption (fasttop): 0x08c787e8 ***
Aborted

If I set the extension functions to return an empty NodeList then I get no errors
(but obviously not the output I want!).

I have also tried creating a new XML::LibXML::NodeList,
cloning each node found from the constant XML file,
setting the owner document to the current XML data
and pushing these nodes onto the new nodelist.
E.G.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
my $dumndlist=XML::LibXML::NodeList->new();
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
my $fn_drgcombo= sub    {
my $tandem_UID=shift || '""';
my $root=shift;

###return $dumndlist;

my $od=$root->get_node(0)->ownerDocument();
my $newl=XML::LibXML::NodeList->new();
my $nl=$drgcombo->findnodes('/DRGCOMBOLIST/item[ UID='.$tandem_UID.']');
for my $n ($nl->get_nodelist() )        {
       my $nn=$n->cloneNode(1);
       $nn->setOwnerDocument($od);
       $newl->push($nn);
       }

return $newl;
};
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

but I still get the memory error.

Any idea how to return a nodelist from an extension function in XML::LibXSLT
(or is this a bug)?


Thanks

Mike Trotman





Message Scanned by ClamAV on datalucid.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]