It really a bad idea to use disable-output-escaping to emit markup. It's
contrary to the design of XSLT and is an abuse of the
disable-output-escaping directive. I would encourage you to consider more
appropriate solutions, like using the document() function to parse a file
that contains the HTML content you want to generate, and copy that to the
result tree. If your stylesheet specifies that you want HTML, you'll get
the appropriate HTML on the output. You could also embed literal result
elements within the stylesheet and pass the content of those elements in as
params.
Have a look at the archives of the Mulberry Technologies XSL list for
constant discussion of this very topic. Everyone falls into the trap of
thinking that the result of a transformation is serialized markup, but
that's not the case. The processor is designed to produce a result tree,
which is then serialized using the format specified out the xsl:output
element. If you write your stylesheets with that in mind, you'll have much
better success than resorting to hacks using disable-output-escaping.
If you decide to continue doing things the way you're doing, you need to
remember that a stylesheet parameter is an XPath expression, not a literal
string. To make something a literal string you need to enclose it within
single or double quotes:
'This is literal text with <text>markup<text/> embedded in it.'
If you choose the double quote character as the delimiter, you will not be
able to use it within the string. Likewise, if you choose the single quote
character, you will not be able to use that within the string.
Dave
Arun Ramdas
<[EMAIL PROTECTED] To:
[email protected]
com> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: RE: problems while
linking
02/22/2002 03:09
PM
Hello,
I am actually trying to use setStylesheetParam to replace certain
parameters
in an XSL at runtime
My xsl looks like
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="msg" select="'default value'"/>
<xsl:template match="doc">
<out><xsl:value-of select="$msg" disable-output-escaping="yes"/>
</out>
</xsl:template>
</xsl:stylesheet>
The actual value i am trying to set for "msg" param is a long html string
and i want this string to appear literally(without any loss of characters)
the string i have is
"<p></p>
<a href="adsad> another quote</a>
<p></p>
<hr color="#999999" size="1">
<span class="f1"><sup>©</sup>2001 All
rights reserved. This message is for informational
purpo
ses only. The
information contained in this message does not
consti
tute a recommendation
Information about your account in certain
SmartAlerts me
ssages may travel
through a non-encrypted medium and may be accessed
by un
authorized parties.
We cant respond to e-mails sent t
o this mailbox. If
you have questions, please contact us through the
</span>"
When i try to use setStyleSheetParam, during the transformation i get the
following error
"Extra illegal tokens!\npattern=' '
Is there a set of special characters, that cant be used in
setStyleSheetParam? if so, what are they? and what could be the workaround
so that any character can be made to appear literally?
Any help would be highly apprciated!
Thanks in Advance,
Arun