Assigning Attribute Values to Variables
Novell Cool Solutions: Trench
By Volker Scheuber
Digg This -
Posted: 13 Nov 2003
I want to assign the value of the modified attribute (SB-TIPSOL) to a variable (VAR-TIPSOL), can someone toss me an example?
A modify event has only (but always) 2 possibilities to manipulate an attribute: it can remove values and it can add values.
You said you want to capture the value of the modified attribute, so I assume you want to capture the new value (if there is one) of the attribute.
The other question is, how to design your template. e.g.: if you need to do other transformations on the same modify event and these other transformations need the variable you're trying to assign, I'd suggest you match on the "root" of the modify event. if, on the other hand, you only need the variable once for a specific calculation, I suggest matching at the deepest possible level. the following two templates should both do what you want, but only one might really fit your needs in the context of the whole style sheet:
<!-- match the root of modify events for class user. -->
<!-- only capture the new value and only the first, if multiple values have been added. note: the variable will be empty, if only a value has been removed. -->
<xsl:variable name="VAR-TIPSOL" select="./modify-attr[@attr-name='SB-TIPSOL']/add-value/value"/>
<!-- match at the deepest possible level. this matches only the first value that has been added to the attribute. -->
<!-- the variable is somewhat superficious, as the variable name is already longer than the xPath statement "." (dot). -->
<xsl:variable name="VAR-TIPSOL" select="."/>
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com