[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Passing thru numerical character ref
Warren Hedley writes: > The following might work. > > <xsl:text disable-output-escaping="yes"><![CDATA[ΰλη]]></xsl:text> It works only if you need to insert a piece of text within a stylesheet. But when the text to be quoted resides *in the XML source*, the stylesheet cannot control the output. Instead, one can redefine the default rule for #PCDATA elements: <xsl:template match="text()"> <xsl:value-of disable-output-escaping="yes" select="."/> </xsl:template> It is really dangerous, as you cannot write things like & in your code any more - instead, you should put it as &amp; or <![CDATA[&]]>. To limit the damage, I would suggest wrapping all Greek text into a special element - say, <greek-quote> - and applying the redefined template to its data children only: match="greek-quote/text()". As a radical workaround, one can look for a specific character and replace it with a quoted sequence: <xsl:template match="greek-quote/text()"> <xsl:call-template name="replace-char"> <xsl:with-param name="string-to-quote" select="."/> <xsl:with-param name="char" select="'ΰ'"/> <xsl:with-param name="replacement" select="'&#x3b0;'"/> </xsl:call-template> </xsl:template> <!-- This template replaces all occurrences of a certain substring --> <!-- by another substring, and disables output escaping for the --> <!-- newly substituted part. --> <xsl:template name="replace-char"> <xsl:param name="string-to-quote"/> <xsl:param name="char"/> <xsl:param name="replacement"/> <xsl:choose> <xsl:when test="contains($string-to-quote, $char)"> <xsl:value-of select="substring-before($string-to-quote, $char)"/> <xsl:value-of disable-output-escaping="yes" select="$replacement"/> <xsl:call-template name="replace-char"> <xsl:with-param name="string-to-quote" select="substring-after($string-to-quote, $char)"/> <xsl:with-param name="char" select="$char"/> <xsl:with-param name="replacement" select="$replacement"/> </xsl:call-template> </xsl:when> <xsl:otherwise><xsl:value-of select="$string-to-quote"/></xsl:otherwise> </xsl:choose> </xsl:template> This is a really dirty hack - a replacement template should be run for every character you need to quote! Efficiency drawbacks are evident, but... it lets you write normal XML sources. When Xalan bug is fixed, you just throw away this chunk, and you're back to normality ;-). Regards, Nikolai Grigoriev XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|