Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 12th, 2009, 08:00 PM
Registered User
 
Join Date: Nov 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old November 12th, 2009, 08:10 PM
mhkay's Avatar
Wrox Author
Points: 18,410, Level: 59
Points: 18,410, Level: 59 Points: 18,410, Level: 59 Points: 18,410, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,949
Thanks: 0
Thanked 289 Times in 284 Posts
Default

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.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #3 (permalink)  
Old November 12th, 2009, 09:55 PM
Registered User
 
Join Date: Nov 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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"/>
Reply With Quote
  #4 (permalink)  
Old November 13th, 2009, 06:28 AM
mhkay's Avatar
Wrox Author
Points: 18,410, Level: 59
Points: 18,410, Level: 59 Points: 18,410, Level: 59 Points: 18,410, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,949
Thanks: 0
Thanked 289 Times in 284 Posts
Default

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.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #5 (permalink)  
Old November 13th, 2009, 10:28 AM
Registered User
 
Join Date: Nov 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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"/>
Reply With Quote
  #6 (permalink)  
Old November 13th, 2009, 10:42 AM
mhkay's Avatar
Wrox Author
Points: 18,410, Level: 59
Points: 18,410, Level: 59 Points: 18,410, Level: 59 Points: 18,410, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,949
Thanks: 0
Thanked 289 Times in 284 Posts
Default

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.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing javascript variable in xsl:value-of select eruditionist XSLT 2 September 19th, 2008 06:23 PM
Passing data via querystring LanceRoss Beginning VB 6 3 July 25th, 2008 01:20 PM
Passing a querystring value that contains '&' jfrizelle Classic ASP Databases 3 March 20th, 2006 09:27 PM
Passing URL in a Querystring hugh@kmcnetwork.com Javascript How-To 3 July 8th, 2004 05:59 PM



All times are GMT -4. The time now is 02:05 AM.


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