[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Set variable via contents of <variable> element
As I understand it, I can set the value of a variable in two ways: 1. By the "select" attribute of the <variable> element: <xsl:variable name="myvariable" select="'myvalue'"/> 2. By the contents of the <variable> element: <xsl:variable name="myvariable"> My value </xsl:variable> I can set the value of a new variable to the value of an existing variable by the first method, and it works fine as in this example: <xsl:template match="item"> <xsl:variable name="this" select="."/> <xsl:variable name="usethis" select="$this"/> I can now use the variable $usethis to access elements of the current node set, including ancestors of the current node, so the following works: <grandparentid><xsl:value-of select="$usethis/../../id"/></grandparentid> Presumably in this case $usethis" must be a pointer or reference to the current node in the input document (as opposed to a copy of the current node) so I can navigate away from it through the input document to access ancestors etc. (sorry if I'm not using the correct terms to describe what I mean). But how do I set the variable using the second method? I can't get it to work in the same way. It would seem that I have to use copy-of or value-of in the body of the <variable> element, but this doesn't achieve the same effect. The reason I need to do this is because I want to set the variable 'usethis' to the result of a <choose> element which (as far as I know) I cannot include in a "select" attribute. Also in my real example 'this' is a parameter. Thanks - Rowan
|
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
|