Subject: RE: [xsl] newbie question|
From: Madhavi Thottempudi <madhavi@xxxxxxxxxxxxxxx>
Date: Tue, 29 Oct 2002 13:07:14 +0000
Thanks for UR replies! I think this would be a good solution for my problem. I will try this one
best regards -M
|Thanks for UR reply. That clears my doubts. |But what if U have too many variables in UR page?? Ex: for a |registration form. |Is there any way I can escape filling my page with when-otherwise |statements (one for each variable)??
it depends on what you mean. if you're talking about creating one variable that has the same value all throughout the entire stylesheet, then you can create a global variable at the top of the page (i.e. before you declare any templates) and use that variable throughout your stylesheet. the syntax is exactly the same as with the previous one, but as you're using a relative xpath that might not be what you're looking for.
another option could be to use a template to provide the necessary value. something along these lines might be what you're looking for:
(in your template):
<xsl:variable name="uContact> <xsl:apply-templates select="." mode="get_variable" /> </xsl:variable>
(as a template in your stylesheet):
<xsl:template match="*" mode="get_variable">
<xsl:value-of select="./selection/email" />
<xsl:when ... />
<xsl:value-of select="//request/param[@name='email']" />
<xsl:value-of select="$uContact" />
this would effectively call the above template which would populate the variable "uContact" according to your choose statement, and then pass back this value to the template that called it. i've not tested that code, although i've used similar code in my own templates.
is that more what you were looking for?
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list