I'm using XSLT to create a HTML output page. I need to add a doctype to the output page. I googled and this seems to be able to get it working:
<xsl:output
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
/>
So I added it to a test transformation file, transform.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
/>
<xsl:template match="/">
<html>
<head>
<title>test</title>
</head>
<body>
content!
</body>
</html>
</xsl:template>
</xsl:stylesheet>
But the output HTML does not contain a doctype... . The rest of the example ... comes out fine.
What am I doing wrong, why isn't the doctype added?
Thanks!
EDIT: problem solved, I'm using eXist and it seems the xsl:output instruction will not work, the solution: mailing list
I can think of two possible answers
(a) your XSLT processor is not conformant with the spec, or
(b) your XSLT processor is not doing the serialization of the result tree, something else is. If the serialization is done by something other than the XSLT processor (e.g. if you send output to a DOM and then use the DOM serializer) then the XSLT serialization properties will be ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With