Leser: 14
Quoteparse_stylesheet($stylesheet_doc)
$stylesheet_doc here is an XML::LibXML::Document object (see XML::LibXML) representing an XSLT file. This method will return a XML::LibXSLT::Stylesheet object, or undef on failure. If the XSLT is invalid, an exception will be thrown, so wrap the call to parse_stylesheet in an eval{} block to trap this.
IMPORTANT: $stylesheet_doc should not contain CDATA sections, otherwise libxslt may misbehave. The best way to assure this is to load the stylesheet with no_cdata flag, e.g.
my $stylesheet_doc = XML::LibXML->load_xml(location=>"some.xsl", no_cdata=>1);
Quotecompilation error: file OrderResponse_openTRANS_DE.xsl line 2 element stylesheet
xsltParseStylesheetProcess : document is not a stylesheet
1
2
3
4
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:script>
1
2
3
4
5
6
7
8
9
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
my $source = $parser->parse_file($strXslPath);
my $style_doc = $parser->parse_file($xsl);
my $stylesheet = $xslt->parse_stylesheet($style_doc);
my $results = $stylesheet->transform($source);