[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Set variable via contents of <variable> element
Rowan Sylvester-Bradley wrote:
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'"/> That way the variable 'myvariable' is of type string. 2. By the contents of the <variable> element: <xsl:variable name="myvariable"> My value </xsl:variable> That way, with XSLT 1.0, the variable 'myvariable is of type result tree fragment. With XSLT 2.0, the variable is of type document-node() I think. 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. Do you use XSLT 1.0 or 2.0? With 2.0, are you aware of the XPath 2.0 if (condition) then expression1 else expression2 conditional expression that might help to use <xsl:variable name="myvariable" select="if (someCondition) then foo else bar"/> to use the select attribute. For XSLT 2.0 also http://www.w3.org/TR/xslt20/#variable-values might help, in particular that table explaining how combining the 'select' attribute and/or the 'as' attribute and/or the content of xsl:variable decide the type of the variable. -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
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
|