Re: [xsl] how to output a processing instruction

Subject: Re: [xsl] how to output a processing instruction
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 19 May 2010 13:32:24 +0200
Nnaemeka David wrote:

i was reading the xslt 1.0 recommendation but could not output the example processing instruction to an html file. <xsl:processing instruction name="xml-stylesheet">href="me.css" type="text/css"</xsl:processing-instruction> i tried several ways, first of all through the head element and lastly, replacing the text nodes with two <xsl:attribute > tags with the href and type being attribute value templates. i still couldn't. can someone help me out and show me how to insert a <?xml-stylesheet...?> into the html output?


<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns="http://www.w3.org/1999/xhtml";
  version="1.0">

<xsl:template match="/">
<xsl:processing-instruction name="xml-stylesheet">href="me.css" type="text/css"</xsl:processing-instruction>
<html>
...
</html>
</xsl:template>



should do, assuming you want to create an XHTML result document to be parsed as XML by an user agent.


If you want to create text/html output then I would not use xsl:processing-instruction to link to a stylesheet, instead I would put an HTML "link rel=stylesheet" element in the head section of the HTML document.

--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread