Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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
 
Old November 12th, 2009, 08:10 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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
 
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"/>
 
Old November 13th, 2009, 06:28 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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
 
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"/>
 
Old November 13th, 2009, 10:42 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.