Thursday, July 12, 2012 12:10 PM
I have a question on using last() in XSL.
Say I have the XML like:
Now I always want to choose the values from the last set of Table.
So I write - \\Tables\Table\F1[last()] simillarly for F2 as well. This works correctly. But at times in the last set of Table F2 can be missing which means last Table will not have F2 at all and the last but one table might have F2. the above method to pull the F2 fails here - If the last set of Table does not have F2 and if the previous set of Table has - it pulls that value. How can I avoid that? Could you please help.
I want to pull the values only from the last set of Table.
I need this as a variable for each element within last set ot Table.
eg: <xsl:variable name="ValF1" select="\\Tables\Table\F1[last()]"/> and so on..
Thursday, July 12, 2012 12:20 PM
Well first of all XPath uses forwards slashes "/" to separate steps, not backslashes.
in my understand selects the last F1 child element of all Table child elements, as the predicate is applied on the step.
So basically if you want the last F1 element in the complete document you need
If you want the F1 child element of the last Table element you need
MVP Data Platform Development My blog
- Marked As Answer by RPaul18 Thursday, July 12, 2012 1:25 PM
Thursday, July 12, 2012 1:26 PMThanks very much Martin, your suggestion worked.