Subject: [xsl] generating ampersand for html "a href=" From: Robert Gretta <robert.gretta@xxxxxxxx> Date: Wed, 31 Jan 2001 15:19:28 -0600 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] method to parse date time, Jeni Tennison | Thread | RE: [xsl] generating ampersand for , Michael Kay |
[xsl] java servlet with xsl/xml tra, Robert Koberg | Date | Re: [xsl] matching <br/> v. <br></b, Robert Koberg |
Month |