[xsl] "grouping" footnote numbers

Subject: [xsl] "grouping" footnote numbers
From: Emma Burrows <Emma.Burrows@xxxxxxxxxxx>
Date: Tue, 11 Oct 2011 10:06:55 +0100
A bit of fun for you all. I have a bunch of XML documents containing footnote
references in the form <xref href="footnote-xyz" type="fn" />.

When converting this to HTML, I am inserting a footnote reference like so:

<a href="footnote-xyz"><sup><xsl:number level="any"
count="xref[@type='fn']"/></sup></a>

This is fine and I end up with little consecutively-numbered references as
you'd expect.

However, it often happens that footnote references within a document refer to
the same footnote - in that case, they'd like the footnotes to have the same
reference number. I am not entirely sure how to go about this.

Presumably, I'd need to count the xrefs after grouping them based on their
href, but I'm not clear on how to apply that to <xsl:number/>. Or should I go
for a bespoke function or template that assigns a number to each xref/@href in
the document and then allocate that to the current xref based on its @href? (I
may have answered my own question there, but I thought I'd see what other
people think :)

Thanks!

Current Thread