[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: problem using last() within <xsl:for-each-group>
From: Matt Heckel <matt_heckel@xxxxxxxxx>
Date: Fri, 1 Apr 2005 02:26:28 -0800 (PST)
matt heckel
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.