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

Re: Building Dynamic Urls

Subject: Re: Building Dynamic Urls
From: George Cristian Bina <george@xxxxxxx>
Date: Sat, 07 May 2005 11:28:02 +0300
build url
Hi Adam,

You need to move the logic inside the variable, something like below:

<xsl:variable name="newURL">
    <xsl:value-of select="$url"/>
    <xsl:if test="child::area">
        <xsl:text>?area=</xsl:text>
        <xsl:value-of select="area"/>
    </xsl:if>
    <xsl:if test="child::action">
        <xsl:text>?action=</xsl:text>
        <xsl:value-of select="action"/>
    </xsl:if>
    <xsl:if test="child::page">
        <xsl:text>?page=</xsl:text>
        <xsl:value-of select="page"/>
    </xsl:if>
</xsl:variable>
<xsl:value-of select="$newURL"/>

with
<xsl:param name="url" select="'http://www.example.com/test'"/>
and
<area>1</area>
<action>2</action>
<page>3</page>
in the source will give you
http://www.example.com/test?area=1?action=2?page=3

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Adam J Knight wrote:
Hi all,

I am wanting to build dynamic urls in xslt by using string concatenation,
unless there is a better way. My stylesheet will be sent a $url parameter to
provide the base of the url. From their my logic is as follows:
<xsl:if test="child::area">
Building_url = $url and "?area=" and <xsl:value-of select="area"/>
</xsl:if>


<xsl:if test="child::action">
  Building_url = $url and "&action=" and <xsl:value-of select="action"/>
</xsl:if>

<xsl:if test="child::page">
  Building_url = $url and "&page=" and <xsl:value-of select="page"/>
</xsl:if>

I as I understand it, xsl variables can't be changed once given a value.
So what would be the best way to go about building these dynamic urls.

Help appreciated!

Cheers, Adam

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.