xsl-list
[Top] [All Lists]

Re: alphabetic counters - Solved

2004-05-11 05:13:35
For the archives, here is the final solution:

XML:
<food cite="bob1"/>
<food cite="bob2"/>
<food cite="jim"/>
<citation id="bob1" author="Bob et al." year="2004" title="Fish &amp; Chips" /> <citation id="bob2" author="Bob et al." year="2004" title="Bangers &amp; Mash" /> <citation id="jim" author="Jim et al." year="2004" title="Toad in the Hole" />

XSLT:
<xsl:key name="refs" match="citation" use="concat(@author,'+', @year)" />

<xsl:for-each select="food">
  <xsl:value-of select="id(@cite)/@author" />
  <xsl:text> </xsl:text>
  <xsl:value-of select="id(@cite)/@year" />
  <xsl:variable name="cite" select="@cite" />
<xsl:if test="count(key('refs', concat(id(@cite)/@author,'+',id(@cite)/@year))) &gt; 1"> <xsl:for-each select="key('refs', concat(id(@cite)/@author,'+',id(@cite)/@year))"> <xsl:if test="@id = $cite"><xsl:number value="position()" format="a" /></xsl:if>
    </xsl:for-each>
  </xsl:if>
</xsl:for-each>

Output:
Bob et al. 2004a
Bob et al. 2004b
Jim et al. 2003


Thanks to all who helped with this!
- Nick.



<Prev in Thread] Current Thread [Next in Thread>