I am using XSLT and should dynamically generate doctype in the converted output based on the parameter. I heard that this cannot be done using XSLT 1.0, but it can with version 2.0 using the result-document tag .
So far, after answering the this question , I have something like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" indent="yes"/>
<xsl:param name="doctype.system" select="'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'" />
<xsl:param name="doctype.public" select="'-//W3C//DTD XHTML 1.0 Strict//EN'" />
<xsl:template match="/">
<xsl:result-document doctype-public="{$doctype.public}" doctype-system="{$doctype.system}" method="html">
<html>
<head>
<xsl:apply-templates select="report/head/node()"/>
</head>
<body>
</body>
</html>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
The problem with the above does not display the result!
If I remove the tags of the results and documents from the foregoing, my conversion is applied and the document is output as expected.
Any clues? Am I using the result document tag correctly?
. , - ( )
( ):
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
:
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body></body>
</html>
:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:result-document doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" method="html">
<html>
<head>
</head>
<body>
</body>
</html>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>