This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: How to robustly handle mutiple condition inputs in Xslt format( Previously Re:Re:How to create variable element from a couple of strings).
- To: "Yang" <sfyang at unisvr dot net dot tw>
- Subject: Re: [xsl] How to robustly handle mutiple condition inputs in Xslt format( Previously Re:Re:How to create variable element from a couple of strings).
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 25 May 2001 10:50:03 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <001001c0e4f5$f19d1d20$1601800a@hqlab.unisvr>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Sun-Fu,
> May be the best approach I can do is to hard-wire these variables
> which are also pointed by mike brown. So I drive substring-before
> and substring-after function to explicitly list out the variables
> from the given **string*.
What about building an XML structure to hold the values, converting
that to a node set, and then indexing into that when you want to use
the 'variables'?
So something like:
<xsl:template match="/">
<xsl:variable name="variables-rtf">
<xsl:call-template name="decompose">
<xsl:with-param name="s" select="$string"/>
<xsl:with-param name="nx" select="$vname"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="variables"
select="msxsl:node-set($variables-rtf)/variable" />
<xsl:value-of select="$variables[@name = 'x3']" />
</xsl:template>
<xsl:template name="decompose">
<xsl:param name="s" />
<xsl:param name="nx" />
<xsl:if test="string($s)" >
<variable name="{substring-before($nx, ',')}">
<xsl:value-of select="substring-before($s,',')"/>
</variable>
<xsl:call-template name="decompose">
<xsl:with-param name="s" select="substring-after($s,',')"/>
<xsl:with-param name="nx" select="substring-after($nx,',')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Although if you're calling it from Javascript, you could always pass
in $variables directly as a parameter (you can have an RTF parameter
if you use Javascript to access MSXML).
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list