|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using variables or parameters in tests
firstly, obligatory daily comment on this list:-) don't do this: <xsl:variable name="actualelectricity"> <xsl:value-of select="sum(/statement/item[$datetest and $electricitytest]/amount)"/> </xsl:variable> do this <xsl:variable name="actualelectricity" select="sum(/statement/item[$datetest and $electricitytest]/amount)"/> as it's less to type and loads more efficient as the variable then holds a number not a result tree fragment with a root node and a text node with string value the decimal representation of a number. However that doesn't really address your question... datetest = (date >= 20050228) variables hold values not expressions, so you while this <xsl:value-of select="sum(/statement/item[$datetest and $electricitytest]/amount)"/> is legal; $datetest would be a constant holding whatever value it is bound to, it wouldn't get a new value relative to each item node. in xslt1 if you want to store an expression that is going to be re-evaluated you need to put it in a named template. Then you could call that so long as you replaced sum(..) with a recursive template that iterated over the nodes calculating the sum and calling your named templates. in xslt2 draft you could define datetest as a function something like <xsl:function name="my:datetest" as="xs:boolean"> <xsl:param name="here"/> <xsl:sequence select="$here/date >= 20005028"/> </xsl:function> and similarly your other test then <xsl:value-of select="sum(/statement/item[my:datetest(.) and my:electricitytest(.)]/amount)"/> David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
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
|

Cart








