This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: generating ampersand for html "a href="
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] generating ampersand for html "a href="
- From: "Clapham, Paul" <pclapham at core-mark dot com>
- Date: Wed, 31 Jan 2001 13:36:41 -0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
I hear there's nothing wrong with having & in your link. Does it not
work in your browser? Try it.
PC2
-----Original Message-----
From: Robert Gretta [mailto:robert.gretta@hand.com]
Sent: January 31, 2001 13:19
To: 'XSL-List@lists.mulberrytech.com'
Subject: [xsl] generating ampersand for html "a href="
Hello,
I've been using xsl about a month and i've come across a case that I wish to
generate an html link that looks like.
<a href="page?param=val¶m2=val2>
I thought that this would be a pretty basic thing. And i have 2 xsl books
and various resources but have yet to find a clear answer on how to format
such a monster without it getting hairy. So, I've just broken down and
decided to ask.
I've tried many things to get the "&" to come out not as an "&" but the
only thing that succeeds is xsl:value-of with disable-output-escaping.
interestingly i have no problem generating <% symbols.
here is a code snippet that will better describe my dilemma.
<xsl:output method="html" /> <!-- note that output method is HTML
-->
<xsl:variable name="aand"><![CDATA[&]]></xsl:variable>
<xsl:variable name="jsp-begin"><![CDATA[<% ]]></xsl:variable>
...
<a href="{$jsp-begin} {$aand}" />
...
the output is:
<a href="<% &" />
but i want
<a href="<% &" />
I cannot understand why the "<%" comes through and the "&" gets
translated... unless this is an Xalan problem.
I had hoped that setting the output method=html would not translate the & in
a CDATA statement but hey, what do i know?
I had created a template to format the href and passed the href in as a
parameter when i noticed this quirk.
<xsl:template name="format-href">
<xsl:param name="href" ></xsl:param>
<a href="$href" />
</xsl:template>
the output is:
<a href="<% &" />
the way to fix the template is something like the following... which seems
like overkill.
<xsl:template name="format-href">
<xsl:param name="href" ></xsl:param>
<![CDATA[<a href="]]><xsl:value-of select='$href'
disable-output-escaping="yes"/><![CDATA[/>]]>
</xsl:template>
the output is
<a href="<%&/">
which is still wrong... or i consider it to be wrong since i think that the
CDATA sections should protect the characters from being translated.
Q: Is there a better way to build an href and pass it around
(xsl:call-template... xsl:with-param) without it being translated?
Q: Is there a way to tell the processor not to translate (escape) the
CDATA sections?
Q: Should I be using a different output method?
Q: Should I be using the "cdata-section-elements" attribute of
"xsl:output" ?
Any help would be appreciated.
Thanks,
Bobby
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list