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

alphabetic counters

Subject: alphabetic counters
From: Nicholas Shanks <contact@xxxxxxxxxxxxxx>
Date: Mon, 10 May 2004 16:50:23 +0100
nick racca
I couldn't find a solution to this in the archives.
I'm also an XSLT newbie so go easy :)

I have the following XML snippit:

<catalogue>
<star>
<name>OGLE-TR-56</name>
<planet>
<reference cite="konacki2003" />
</planet>
</star>
<citation id="konacki2003" title="A New Transiting Extrasolar Giant Planet" author="Konacki et al." year="2003" journal="Nature" volume="421" pages="507" href="http://arxiv.org/abs/astro-ph/0301052" />
</catalogue>


Which is processed by this XSLT fragment:

<xsl:for-each select="reference">
<xsl:text disable-output-escaping="yes"><![CDATA[<a href="#]]></xsl:text><xsl:value-of select="@cite"/><xsl:text disable-output-escaping="yes"><![CDATA[">]]></xsl:text>
<xsl:value-of select="id(@cite)/@author" />
<xsl:if test="id(@cite)/@year != ''"><xsl:text> </xsl:text><xsl:value-of select="id(@cite)/@year" /></xsl:if>
<xsl:text disable-output-escaping="yes"><![CDATA[</a>]]></xsl:text>
<xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each>


Producing this XHTML:

<a href="#konacki2003">Konacki et al. 2003</a>


What my problem is, is that references like the above are supposed to be suffixed by a lower case alphabetic character ('a', 'b', etc.) after the year if there are multiple 'citation' elements with identical values for 'author' and 'year'. I have no idea how to go about doing this. Can anyone suggest how to do this?


Breaking it down:
1) get the <citation> element with the id given in @cite
2) get the author and year attributes from that citation
3) search though all <citation> elements for any with matching (author && year) values
4) if count > 1, see which search result corresponds to the ID we want and append the appropriate letter of the alphabet (i.e. 'c' if the original ID was the third found in step 3)


Thanks for reading.

- 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.