|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] grouping/position problem
I'm having some problems with grouping and position().
For illustration, you could imagine an input source like: <list> <item author="five" year="2001"/> <item author="three" year="2003"/> <item author="four" year="2002"/> <item author="two" year="1998"/> <item author="one" year="2005"/> <item author="two" year="2000"/> <item author="four" year="1999"/> </list> I need to group and sort by author, then by year, and then pass some parameters that are based on the item's position within -- in this case -- the author group. I have this template: <xsl:template match="mods:modsCollection" mode="sort_author-year"> <xsl:variable name="bibref" select="mods:mods" /> <xsl:for-each-group select="$bibref" group-by="bib:grouping-key(.)"> <xsl:sort select="current-grouping-key()"/> <xsl:variable name="author-position" select="position()"/> <xsl:variable name="shorten-author" as="xs:boolean" select="$author-position > 1" /> <xsl:for-each-group select="current-group()" group-by="bib:year(.)"> <xsl:sort select="current-grouping-key()" /> <xsl:variable name="year"> <xsl:value-of select="current-grouping-key()"/> <xsl:if test="last() > 1"> <xsl:number value="position()" format="a"/> </xsl:if> </xsl:variable> <xsl:for-each select="current-group()"> <xsl:apply-templates select="mods:titleInfo"> <xsl:with-param name="year" select="$year"/> <xsl:with-param name="shorten-author" select="$shorten-author"/> </xsl:apply-templates> </xsl:for-each> </xsl:for-each-group> </xsl:for-each-group> </xsl:template> The bib:grouping-key function constructs an author names string to sort. The problem is the author-position variable. What I want is for it to measure position within an author group. But I'm getting these sorts of results: AUTHOR POSITION: 1
SHORTEN: false
AUTHOR POSITION: 2
SHORTEN: true
AUTHOR POSITION: 2
SHORTEN: true
AUTHOR POSITION: 3
SHORTEN: true
AUTHOR POSITION: 4
SHORTEN: true
AUTHOR POSITION: 4
SHORTEN: true
AUTHOR POSITION: 5
SHORTEN: true
AUTHOR POSITION: 6... which tells me it's measuring the position of the group itself. What I'm wanting is: AUTHOR POSITION: 1
SHORTEN: false
AUTHOR POSITION: 1
SHORTEN: false
AUTHOR POSITION: 2
SHORTEN: true
AUTHOR POSITION: 1
SHORTEN: false
AUTHOR POSITION: 1
SHORTEN: false
AUTHOR POSITION: 2
SHORTEN: true
AUTHOR POSITION: 1
SHORTEN: false
AUTHOR POSITION: 1
SHORTEN: falseHow do I fix this? Bruce
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








