# position variables

**URL:** <https://discourse.citationstyles.org/t/position-variables/59>\
**Category:** CSL Development\
**Created:** [April 12, 2005, 9:20am UTC](https://discourse.citationstyles.org/t/position-variables/59 "2005-04-12T09:20:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruce\_D\_Arcus](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@Bruce\_D\_Arcus](https://discourse.citationstyles.org/u/Bruce_D_Arcus)\
**Post date:** [April 12, 2005, 9:20am UTC](https://discourse.citationstyles.org/t/position-variables/59/1 "2005-04-12T09:20:19Z")

</div>

OK,

I tried to figure out how to apply David’s fix for one part of the  
grouping problem to the rest, since this bug MUST get fixed ASAP. So,  
I tried to create a new variable (“author-position”) to figure out the  
position within an author group. Here’s what I have:

```
             <xsl:when test="$sort_order-bib='author-year'">
                 <xsl:for-each 

```

select="$raw-biblist/mods:modsCollection"\>  
\<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:for-each-group select="current-group()"
                             group-by="bib:year(.)">
                             <xsl:sort 

```

select=“current-grouping-key()”/\>  
\<xsl:variable name="author-year-count"  
select=“count(current-group())”/\>  
\<xsl:apply-templates  
select=“current-group()“  
mode=“current-group”\>  
\<xsl:with-param  
name=“author-year-count"  
select=”$author-year-count”/\>  
\<xsl:with-param  
name=“author-position"  
select=”$author-position”/\>  
\</xsl:apply-templates\>  
\</xsl:for-each-group\>  
\</xsl:for-each-group\>  
\</xsl:for-each\>  
\</xsl:when\>

However, I get this result on the sample file:

Current author-year position: 1 Current author position: 1  
Current author-year position: 1 Current author position: 2  
Current author-year position: 2 Current author position: 2  
Current author-year position: 1 Current author position: 3  
Current author-year position: 1 Current author position: 4  
Current author-year position: 1 Current author position: 4  
Current author-year position: 1 Current author position: 5  
Current author-year position: 1 Current author position: 6

What I expect is:

Current author-year position: 1 Current author position: 1  
Current author-year position: 1 Current author position: 1  
Current author-year position: 2 Current author position: 2  
Current author-year position: 1 Current author position: 1  
Current author-year position: 1 Current author position: 1  
Current author-year position: 1 Current author position: 2  
Current author-year position: 1 Current author position: 1  
Current author-year position: 1 Current author position: 1

Any ideas?

Bruce
