github.com/matislovas/ratago@v0.0.0-20240408115641-cc0857415a7a/xslt/testdata/general/bug-90.xsl (about) 1 <?xml version="1.0"?> 2 <!-- 3 ============================================================ 4 This is a stylesheet that will create, for each input <fruit> element, 5 two output elements - <new-fruit1> and <new-fruit2> , each of 6 which should wrap the content of the the input fruit/site element 7 in a CDATA block. 8 <new-fruit1> does this 'properly' via cdata-section-elements 9 <new-fruit2> does it with a workaround named template 'wrap-cdata' 10 ============================================================ 11 --> 12 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 13 <xsl:output method="xml" cdata-section-elements="new-fruit1" indent="yes"/> 14 <xsl:template match="fruit-sites/fruit"> 15 <new-fruit1 type="{@type}"> 16 The site is at 17 <xsl:value-of select="./site"/> 18 </new-fruit1> 19 <new-fruit2 type="{@type}"> 20 <xsl:call-template name="wrap-cdata"> 21 <xsl:with-param name="content"> 22 The site is at <xsl:value-of select="./site"/> 23 </xsl:with-param> 24 </xsl:call-template> 25 </new-fruit2> 26 </xsl:template> 27 28 <!-- Wrap $content in a CDATA block --> 29 <xsl:template name="wrap-cdata"> 30 <xsl:param name="content"/> 31 <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> <!-- 32 --><xsl:value-of disable-output-escaping="yes" select="$content"/> <!-- 33 --><xsl:text disable-output-escaping="yes">]]></xsl:text> 34 </xsl:template> 35 </xsl:stylesheet>