Subject: Re: [xsl] construct query string From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx> Date: Tue, 07 May 2002 14:15:37 -0600 |
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.
You can create "?a=text&b=&c=&d=more_text" using the stylesheet <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:text>query-string = "</xsl:text> <xsl:apply-templates select="foo/*" mode="query"/> <xsl:text>"</xsl:text> </xsl:template>
<xsl:template match="*" mode="query"> <xsl:if test="position() = 1"> <xsl:text>?</xsl:text> </xsl:if> <xsl:value-of select="local-name(.)"/> <xsl:text>=</xsl:text> <xsl:value-of select="string(.)"/> <xsl:if test="last() != position()"> <xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet>
Greg Faron Integre Technical Publishing Co.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] construct query string, Zack Angelo | Thread | Re: [xsl] construct query string, Joerg Heinicke |
Re: [xsl] question about javascript, Thomas B. Passin | Date | RE: [xsl] construct query string, sara . mitchell |
Month |