varuog
varuog

Reputation: 3081

error in doctype

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <!DOCTYPE HTML>
    <html>
    <head>

    </head>
    <body>

    </body>
    </html>
</xsl:template>

</xsl:stylesheet>

It is getting a parse error in DOCTYPE. how to resolve this?

Upvotes: 2

Views: 282

Answers (2)

Mads Hansen
Mads Hansen

Reputation: 66714

The W3C HTML 5 Reference recommends using doctype-system="about:legacy-compat":

For compatibility with legacy producers of HTML — that is, software that outputs HTML documents — an alternative DOCTYPE is available for use by systems that are unable to output the DOCTYPE given above. This limitation occurs in software that expects a DOCTYPE to include either a PUBLIC or SYSTEM identifier, and is unable to omit them. The canonical form of this DOCTYPE is as follows:

<!DOCTYPE html SYSTEM "about:legacy-compat">

You can achieve this with any XSLT processor with the following:

<xsl:output method="html" doctype-system="about:legacy-compat" />

It will generate:

<!DOCTYPE HTML SYSTEM "about:legacy-compat">

Upvotes: 5

nneonneo
nneonneo

Reputation: 179392

You can't embed the <!DOCTYPE HTML> declaration directly in xslt. Use the following:

<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html></xsl:text>

instead. See Set HTML5 doctype with XSLT for a similar problem.

Upvotes: 2

Related Questions