[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: generating ampersand for html "a href="

Subject: RE: generating ampersand for html "a href="
From: "Clapham, Paul" <pclapham@xxxxxxxxxxxxx>
Date: Wed, 31 Jan 2001 13:36:41 -0800
html a href
I hear there's nothing wrong with having &amp; in your link.  Does it not
work in your browser?  Try it.

PC2

-----Original Message-----
From: Robert Gretta [mailto:robert.gretta@xxxxxxxx]
Sent: January 31, 2001 13:19
To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
Subject:  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&param2=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 "&amp" 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="<% &amp;" /> 

     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="<% &amp;" /> 

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

		&lt;a href="<%&/"&gt;

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.