Subject: RE: [xsl] newbie question From: "Allan Jones" <allan.jones@xxxxxxxxxxxx> Date: Tue, 29 Oct 2002 12:47:37 -0000 |
|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:variable name="uContact"> <xsl:choose> <xsl:when test="//request/param[@name='action']='Edit'"> <xsl:value-of select="./selection/email" /> </xsl:when> <xsl:when ... /> <xsl:otherwise> <xsl:value-of select="//request/param[@name='email']" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:value-of select="$uContact" /> </xsl:template> 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? b XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] newbie question, David Carlisle | Thread | RE: [xsl] newbie question, Madhavi Thottempudi |
Re: [xsl] Encoding/Entities problem, Paulo \(Shape.Tech\) | Date | [xsl] XML Spy 5 question..., Carlos Barroso |
Month |