[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: newbie question
|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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|