This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: construct query string
- From: Joerg Heinicke <joerg dot heinicke at gmx dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 07 May 2002 22:20:51 +0200
- Subject: Re: [xsl] construct query string
- References: <005801c1f5fe$8985f340$0701000a@Westbank>
- Reply-to: xsl-list at lists dot mulberrytech dot com
<root>
<param1>blah</param1>
<param2>blah</param2>
<param3>blah</param3>
</root>
<xsl:template match="root">
<xsl:variable name="query-string">
<xsl:text>?</xsl:text>
<xsl:for-each select="*">
<xsl:value-of select="name()"/>
<xsl:text>=</xsl:text>
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">
<xsl:text>&</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:text>variable $query-string: </xsl:text>
<xsl:value-of select="$query-string"/>
</xsl:template>
Regards,
Joerg
Zack Angelo schrieb:
> I'm attempting to construct a query string ("?param1=blah¶m2=blah2",
> for example) using the values of a series of tags in an XML document. My
> first intuition was to create an XSL variable, and then send the
> transformer into a loop which concats each param tag onto that variable.
> However, after reading the W3C doc, it doesn't seem like that's feasible
> because you can't "shadow" a XSLT variable in the same template context,
> and you can't reference the variable you're trying to declare in the
> variable definition. TIA.
>
> -Zack
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list