This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Is there a way to translate entities into their character equivalents?


The following may do the job, assuming your XSLT processor supports it:

<xsl:if test="blahblahblah">
  <xsl:text disable-output-escaping="yes">&lt;a href="go
away"&gt;</xsl:text>
</xsl:if>
<xsl:apply-templates/>
<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>

But I would strongly encourage you not to use this, as it basically breaks
the XSLT model.  You won't be able to subsequently transform the result
tree, unless you first serialized it into a string and then parsed it again.
There are only a few cases where the stylesheet may go outside its true
domain of transforming trees, and this is one of them, but it is generally
not needed.  There have been many times when I thought I needed to use
disable-output-escaping, but almost every time I discovered that I didn't
need to use this hack.  On pages 301-302, Kay points out a couple instances
where you might need to use it.  If your output is not XML or HTML, for
example, you may wish to use it (although <xsl:output method="text"/> should
do that job too, I would think).  Or if you're trying to generate the
literal "<" for a JavaScript snippet or for the "<%" delimiter for ASP or
JSP, it could be handy.  Otherwise, there should be a way to do what you
want and still stay within the model of transforming trees.  If you post a
more detailed description of what you're trying to do, or at least explain
why you think you need to output unescaped angle brackets, I'll see if I
can't defend my claim.

Hope this helps,

Evan Lenz
elenz@xyzfind.com
http://www.xyzfind.com


-----Original Message-----
From: owner-xsl-list@mulberrytech.com
[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Steve Carton
Sent: Thursday, August 17, 2000 8:51 AM
To: XSL mailing-list
Subject: Is there a way to translate entities into their character
equivalents?


I'd like to cheat in my style sheet and do something like this:

<xsl:if test="blahblahblah">&lt;a href="go away"&gt;</xsl:if>
<xsl:apply-templates/>
&lt;/a&gt;

My real world case is much more complex, but is there a way to
have the HTML generated for this contain the <> symbols instead of
the entities?



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]