Re: [xsl] XHTML html validation

Subject: Re: [xsl] XHTML html validation
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 16 Feb 2007 12:58:14 +0100
John Steel wrote:

One more thing: if you want to force a certain string on the beginning of your file, you can use a trick with character-maps in XSLT 2 to get it there. I've put a workaround on this or saxon's list a while ago, but it is easy enough to implement.
Thanks, looks like I need this.



Here's a stylesheet that illustrates that solution. Note, this is an *UGLY* workaround for non-conforming XSLT 2 processors to hack around a bug. You really should use the declaration in my previous post if your processor can handle it.

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
<xsl:output method="xml" use-character-maps="doctype"/>
<xsl:character-map name="doctype" >
<xsl:output-character
character="&#xE050;"
string='&lt;!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>' />
</xsl:character-map>
<xsl:template match="/" name="main">
<xsl:text>&#xE050;</xsl:text>
<html>
<head>
<title>test</title>
</head>
<body>
<p>bla</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Current Thread