xsl-list
[Top] [All Lists]

problem using last() within <xsl:for-each-group>

2005-04-01 03:26:28
Once again, my intuition has failed me and I need
help. I was trying to find the last item within the
last group of a data population and I've run into some
interesting (ie. frustrating) behavior. For the
record, I'm using SAXON8b to process an XSLT V. 2.0
stylesheet.

As I mentioned, I'm grouping using for-each-group and
then iterating through each group using for-each on
the current-group(). While using for-each through the
current-group()using everything seems to be working
just fine. That is, the position() value is sequential
and last() returns the total iterations for the
current-group(). However, in the outer
for-each-group(ing) the last() function doesn't seem
to be returning the right value. Since both for-each
and for-each-group change the context when invoked, it
seems they should both behave the same way?  Also, I
was playing with the current() function and it doesn't
seem to evaluate at all. This is of lesser importance
to me for this particular problem I'm facing but
thought I would ask for future reference. Thanks VERY
much. My source doc and stylesheet are as follows.  

<CASTDataset>
<ETL_AIR_7 ACFT_TYP_SYN_NM="E-2"
CARRIER_NM="Constellation"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="EA-18G"
CARRIER_NM="Constellation"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="F-18C"
CARRIER_NM="Constellation"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="F-18E"
CARRIER_NM="Constellation"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="E-2"
CARRIER_NM="Eisenhower"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="EA-18G"
CARRIER_NM="Eisenhower"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="F-18C"
CARRIER_NM="Eisenhower"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="F-18E"
CARRIER_NM="Eisenhower"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="E-2"
CARRIER_NM="Enterprise"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="EA-18G"
CARRIER_NM="Enterprise"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="F-18C"
CARRIER_NM="Enterprise"/>
<ETL_AIR_7 ACFT_TYP_SYN_NM="F-18E"
CARRIER_NM="Enterprise"/>
</CASTDataset>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:fn="http://www.w3.org/2004/10/xpath-functions";
xmlns:xdt="http://www.w3.org/2004/10/xpath-datatypes";>

<xsl:output method="text" version="1.0"
encoding="UTF-8" indent="yes"
omit-xml-declaration="yes"/>

<xsl:variable name="endline" select="'&#x0ax;'"/>
<xsl:template match="/">
<xsl:for-each-group select="CASTDataset/ETL_AIR_7"
group-by="@CARRIER_NM">
<xsl:value-of select="concat('The current node is ',
current())"/>
<xsl:value-of select="$endline"/>
<xsl:value-of
select="concat(' For the ', @CARRIER_NM, ' group, the
current position is ', position(), ' and last is ',
last())"/>
<xsl:value-of select="$endline"/>
<xsl:for-each select="current-group()">
<xsl:value-of select="concat('For the items within the
current-group(), ACFT_TYP_SYN_NM is ',
@ACFT_TYP_SYN_NM, ',the current position is ',
position(), ' and last is ', last())"/>
<xsl:value-of select="$endline"/>
</xsl:for-each>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>




                
__________________________________ 
Yahoo! Messenger 
Show us what our next emoticon should look like. Join the fun. 
http://www.advision.webevents.yahoo.com/emoticontest

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--