Subject: Re: Passing thru numerical character ref From: "Nikolai Grigoriev" <grig@xxxxxxxxxxx> Date: Thu, 6 Jul 2000 23:08:31 +0400 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Passing thru numerical characte, Warren Hedley | Thread | RE: Passing thru numerical characte, Rigby, David |
XML Pretty Printer, Scott Carlson | Date | Re: Using XSL to create HTML page f, Gary L Peskin |
Month |