[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Variable creation and scoping
<xsl:variable name="c1"> <xsl;value-of select="document('external.xml')/a/b/c/@foo * document('external.xml')/a/b/c/@bar"/> </xsl:variable> Note using xsl:variable with content rather than a select attribute is relatively expensive. the above creates a result tree fragment consisting of a root node containing a text node containing the value as a string. If you went <xsl:variable name="c1" select="document('external.xml')/a/b/c/@foo * document('external.xml')/a/b/c/@bar"/> then the variable would contain a number, which is less to store and quicker to use as a number later. > Is there an easier/cleaner/better way to do this that will allow me to not > edit the xsl when the xml file used to create the variables is altered? Probably but the problem seems a little underspecified? Do you need a variables at all? If there are an unknown number of usable foo bar attribute pairs then it seems like you don't want variables for each product, as that would limit you to a fixed number. I'd go <xsl:variable name="foobar" select="document('external.xml')/a/b/c[string(@foo) and string(@bar)]"/> now $foobar contains all the usable c nodes and to get the 4th product <xsl:value-of select="$foobar[4]/@foo * $foobar[4]/@bar"/> David 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
|