Subject: | standalone="yes" not copied into result XML |
Given this perl code, the standalone="yes" part of the XML declaration will _not_ be in the result XML document (note the xsl:output instruction):
--------- begin
my $strXML = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<a>
text
</a>
';
my $strXSLT = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" standalone="yes" indent="no" />
<xsl:template match="/">
<root>
<node>
<xsl:attribute name="const">1</xsl:attribute>
<xsl:attribute name="time">midnight</xsl:attribute>
<xsl:value-of select="a/child::text()" />
</node>
<node>
<xsl:attribute name="const">2</xsl:attribute>
<xsl:attribute name="time">now</xsl:attribute>
<xsl:value-of select="a/child::text()" />
</node>
</root>
</xsl:template>
</xsl:stylesheet>';
my $oXML = new XML::LibXML();
my $oXSLT = new XML::LibXSLT();
my $oInputDocument = $oXML->parse_string( $strXML );
my $oInputSheet = $oXML->parse_string( $strXSLT );
my $oSheet = $oXSLT->parse_stylesheet( $oInputSheet );
my $oResults = $oSheet->transform( $oInputDocument );
print "\nDEBUG: results string ", $oResults->toString();
--------- end
Note: the version and encoding DO get copied correctly.
Note: xsltproc does have a standalone="yes" in the XML declaration line.
E.g. output:
DEBUG: results string <?xml version="1.0" encoding="utf-8"?>
<root><node const="1" time="midnight">
text
</node><node const="2" time="now">
text
</node></root>