p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Passing xsl variable in hyperlink querystring (http://p2p.wrox.com/showthread.php?t=77009)

b.preetam November 12th, 2009 08:00 PM

Passing xsl variable in hyperlink querystring
 
Hi,
I am coding in xsl which will be later transformed to html
I need to pass more than one xsl variable values in hyperlink, i am facing issues while seperating the two variable names with '&'
i tried using & and &, in both case i get & in between of two variables in source view after transforming to html.

code for hyperlink-
<xsl:attribute name='href'>www.testurl.com/sg/show.aspx?p1=<xsl:value-of select="pass1"/>&p2=<xsl:value-of select="pass2"/></xsl:attribute>
www.testurl.com/sg/show.aspx?p1=<xsl:value-of select="pass1"/>&p2=<xsl:value-of select="pass2"/>
</a>

is there any way to get rid of & in url? Thanks in advance.

Regds,
PB

mhkay November 12th, 2009 08:10 PM

An ampersand in any XML document (including a stylesheet) must be escaped as
Code:

&amp;
to make it valid XML.

The HTML serializer will also output
Code:

&amp;
in the generated HTML. This is required by the HTML specification. It's common for people writing HTML by hand to ignore this rule, and HTML browsers are very forgiving, but the correct form is to escape it, and every browser will accept it in that form.

b.preetam November 12th, 2009 09:55 PM

Micheal,
yes, i followed that. but i dont want &amp; be part of a re-directing url. any suggestions to handle this?

Code:

<xsl:attribute name='href'>www.testurl.com/sg/show.aspx?p1=<xsl:value-of select="pass1"/>&amp;p2=<xsl:value-of select="pass2"/></xsl:attribute>
www.testurl.com/sg/show.aspx?p1=<xsl:value-of select="pass1"/>&amp;p2=<xsl:value-of select="pass2"/>


mhkay November 13th, 2009 06:28 AM

Sorry, I don't understand you requirement. Please explain what output you want. Use the forum [ code ] tags to avoid your code being corrupted by the forum software.

b.preetam November 13th, 2009 10:28 AM

i am getting output as below

Code:

<a href="http://www.testurl.com/sg/show.aspx?p1=12&amp;p2=14">http://www.testurl.com/sg/show.aspx?p1=12&amp;p2=14</a>
presence of &amp; in URL redirects to incorrect link

for the coding in XSL as
Code:

xsl:attribute name='href'>www.testurl.com/sg/show.aspx?p1=<xsl:value-of select="pass1"/>&amp;p2=<xsl:value-of select="pass2"/></xsl:attribute>
www.testurl.com/sg/show.aspx?p1=<xsl:value-of select="pass1"/>&amp;p2=<xsl:value-of select="pass2"/>


mhkay November 13th, 2009 10:42 AM

We're way off topic for XSLT by now. But every browser I know of handles & a m p ; in a URL correctly, that is by treating it as a representation of an ampersand. I don't understand what you mean by saying it redirects to an incorrect link.


All times are GMT -4. The time now is 11:19 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.