Behavior of last()

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I have a question on using last() in XSL.
Say I have the XML like:
<Tables>
<Table>
<F1>1</F1>
<F2>2</F2>
</Table>
<Table>
<F1>3</F1>
<F2>4</F2>
</Table>
<Table>
<F1>5</F1>
<F2>6</F2>
</Table>
Now I always want to choose the values from the last set of Table.
So I write - file://\TablesTableF1[last \TablesTableF1[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=" file://tables/Table/F1[last \TablesTableF1[last ()]"/> and so on..
<hr class="sig Rpaul

View the full article
 
Back
Top