Rrendering a XML::XPath::NodeSet using an XSLT template with XML::LibXSLT

ShonKomsir

New Member
I need to render a node set found via \[code\]XML::XPath\[/code\]\[code\]my $source = XML::LibXML->load_xml(location => 'xml/animals.xml');my $nodeset = $source->find('//area[@id="01"]');\[/code\]using an XSLT template with \[code\]XML::LibXSLT\[/code\]:\[code\]my $xslt = XML::LibXSLT->new();my $style_doc = XML::LibXML->load_xml(location=>'xml/animal_template.xsl', no_cdata=http://stackoverflow.com/questions/10536627/>1);my $stylesheet = $xslt->parse_stylesheet($style_doc);\[/code\]but I can't simply give the nodeset to the \[code\]$stylesheet->transform()\[/code\]:\[code\]my $results = $stylesheet->transform($nodeset);\[/code\]because transform is expecting a \[code\]XML::LibXML::Document\[/code\] object, not \[code\]XML::XPath::NodeSet\[/code\].What should I do? Is there a way to create an \[code\]XML::LibXML::Document\[/code\] from a \[code\]XML::XPath::NodeSet\[/code\]?Or maybe to give the XSLT template a variable so I don't have to find the nodes with XPath?
 
Back
Top