[Home] [By Thread] [By Date] [Recent Entries]
At 2009-03-18 17:53 +0530, Ganesh Babu N wrote:
Dear All, Absolutely there is a way ... in both XSLT 1.0 and 2.0 ... this is a use case I tell students justifies the dangerous disable-output-escaping= attribute. I say "dangerous" because it does not help when the output tree from the transformation is used as the input tree for a subsequent process. It is only helpful when you are serializing your output tree into output angle-bracket syntax, and the processor you are using supports serialization. I hope the example below for both XSLT 1.0 and 2.0 helps. . . . . . . . . Ken t:\ftemp>type ganesh.xml <graphics> <graphic file="1.jpg"/> <graphic file="2.jpg"/> </graphics> t:\ftemp>call xslt ganesh.xml ganesh.xsl
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article
[
<!ENTITY gr1 SYSTEM "1.jpg" NDATA IMAGE>
<!ENTITY gr2 SYSTEM "2.jpg" NDATA IMAGE>
]>
<article><!--The article goes here--></article>
t:\ftemp>type ganesh.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:output indent="yes"/> <xsl:template match="/">
<xsl:text disable-output-escaping="yes"><![CDATA[
<!DOCTYPE article
[
]]></xsl:text>
<xsl:for-each select="/*/graphic">
<xsl:value-of disable-output-escaping="yes"
select="concat('<!ENTITY gr',
substring-before(@file,'.'),
' SYSTEM "',@file,
'" NDATA IMAGE>')"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">]>
</xsl:text>
<article>
<xsl:comment>The article goes here</xsl:comment>
</article>
</xsl:template></xsl:stylesheet> t:\ftemp>
|

Cart



