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]
Other format: [Raw text]

Re: Having Tags when the output method is text


Hi Jeni,
I face a new problem if i use the call template approach you suggested. Whenever i call this template inside any <xsl:attribute> tag, the output escaping doesnt work any more. How could i avoid this?
regards,
swati



----Original Message Follows----
From: Jeni Tennison <jeni@jenitennison.com>
Reply-To: Jeni Tennison <jeni@jenitennison.com>
To: "Swati Attarde" <swatid18@hotmail.com>
CC: XSL-List@lists.mulberrytech.com
Subject: Re: [xsl] Having Tags when the output method is text
Date: Thu, 1 Aug 2002 11:43:38 +0100

Hi Swati,

> Here is my problem description. I have to generate a jsp file using
> xslt . The problem lies in that jsp contains both html tags plus
> some java specific code enclosed in <% generally. If i use the
> output format as html or xml then everywhere i have to disable
> output escaping because in the output file i want < and not &lt; .
> If i use the output format as text, the html tags have to be
> included in the cdata section or else they donot appear in the
> output. Is there any better way where i can obtain the combination
> the text and html and have minimum number of cdatas or disable
> output escapings?

The better way is to use the XML syntax for JSP so that you don't need
to have <%...%> in the output at all. There's a useful
summary/cheat-sheet on the XML syntax for JSP and how it maps to the
normal syntax at http://java.sun.com/products/jsp/pdf/card12.pdf. Once
you're creating XML, of course, there's no disabling of output
escaping required.

If you can't use that, for some reason, you could minimise the number
of disable-output-escapings by creating named template(s) for doing the
messy work, something like:

<xsl:template name="jsp:scriptlet">
<xsl:param name="content" />
<xsl:text disable-output-escaping="yes">&lt;%</xsl:text>
<xsl:value-of select="$content" />
<xsl:text disable-output-escaping="yes">%&gt;</xsl:text>
</xsl:template>

and then calling that named template to create the JSP code:

<xsl:call-template name="jsp:scriptlet">
<xsl:with-param name="content">
... your code in here ...
</xsl:with-param>
</xsl:call-template>

The good thing about doing it that way is that it will make it easy to
switch to the XML syntax later on, when you're able to.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/






------------------------------------------------------------
Eat well, stay fit, die anyway
------------------------------------------------------------




_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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]