Hmm, I thought he wants all the parameters. The correct logic that
generates all of them plus ? and ampersands correctly is something like:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="url" select="'http://www.example.com/test'"/>
<xsl:template match="/*">
<xsl:variable name="newURL">
<xsl:value-of select="$url"/>
<xsl:apply-templates select="*[1]" mode="url"/>
</xsl:variable>
<xsl:value-of select="$newURL"/>
</xsl:template>
<xsl:template match="area|action|page" mode="url">
<xsl:param name="prefix" select="'?'"/>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="name()"/>
<xsl:text>=</xsl:text>
<xsl:value-of select="."/>
<xsl:apply-templates select="following-sibling::*[1]" mode="url">
<xsl:with-param name="prefix" select="'&'"/>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
on
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<area>1</area>
<action>2</action>
<page>3</page>
</doc>
will give:
http://www.example.com/test?area=1&action=2&page=3
Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Aron Bock wrote:
> And in this case one would use <xsl:choose> rather than <xsl:if>
That was my first impulse too, but no, that will not add action if
area is present.
Since it is an URL it should have only 1 "?", which denotes the start of
the query string. So only 1 of those choices should be added
anyway...ergo the <xsl:choose>
--A
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's
FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--