[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Choose variable
Hi Ricardo, > I have an element that I want to modify its value. For example when is 1 > I want 10, 2 -> 15, 3 ->25 and so on. > How can I do that knowing that I use it on different places and I don't > want to go putting "xsl:choose" on all of that places. It would be much > code repeated. > I've tried to put the value on a variable inside an "xsl:choose" but It > is impossible to have many variables with the same name. Instead of putting the variable inside the <xsl:choose>, put the <xsl:choose> inside the variable: <xsl:variable name="newValue"> <xsl:choose> <xsl:when test=". = 1">10</xsl:when> <xsl:when test=". = 2">15</xsl:when> <xsl:when test=". = 3">25</xsl:when> ... </xsl:choose> </xsl:variable> and then reuse $newValue wherever you need it. If you need it in different templates, on the other hand, then you should create a separate template that contains the <xsl:choose> and call that template whenever you need the relevant value; the value itself won't be reused, but the code that calculates it can be. Let us know if you want to see how to do that. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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
|