xsl-list
[Top] [All Lists]

Re: [xsl] XHTML html validation

2007-02-16 05:00:04
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--