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

Re: alphabetic counters - Solved

Subject: Re: alphabetic counters - Solved
From: Nicholas Shanks <contact@xxxxxxxxxxxxxx>
Date: Tue, 11 May 2004 13:13:35 +0100
counters in xslt
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.

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.