Subject: RE: "grouping" footnote numbers
From: Emma Burrows <Emma.Burrows@xxxxxxxxxxx>
Date: Tue, 11 Oct 2011 11:06:16 +0100
|
From: David Carlisle [mailto:davidc@xxxxxxxxx]
>> count="xref[@type='fn']"/></sup></a>
> The secret for numbering any kind of cross reference in xslt is to
> number the thing being referenced, not the reference. Here you want to
> number the footnotes, and you want the cross reference to use the numbr
> of teh references footnote, so
Thank you very much for your solution. I realise I forgot to specify where the
goalposts were in my original post, as I'm dealing with XML chunked up into
fragments in a CMS, so the footnote text, scattered into little documents, is
not that readily available.
Fortunately, the requirement is to restart numbering on each page, so I think
pursuing a solution that numbers the xrefs within the current document based
on their @href is still what I want.
So I am hereby moving the goalposts to a more suitable location. :) Your
example still got me nearly there:
Given this XML:
---------------
<p>blah blah <xref href="footnote-xyz"/></p>
<p>more blah <xref href="footnote-xyz"/></p>
<p>last blah <xref href="footnote-abc"/></p>
This XSL:
---------
<xsl:key name="fn" match="xref" use="@href"/>
...
<sup>
<xsl:for-each-group select="key('fn', @href)" group-by="@href">
<xsl:number level="any"/>
</xsl:for-each-group>
</sup>
Produces this output:
---------------------
<p>blah blah <sup>1</sup></p>
<p>more blah <sup>1</sup></p>
<p>last blah <sup>3</sup></p>
But I would like to get:
------------------------
<p>blah blah <sup>1</sup></p>
<p>more blah <sup>1</sup></p>
<p>last blah <sup>2</sup></p>
So the desired output is for the references to "footnote-xyz" to both be
numbered "1", but the reference to "footnote-abc" to be numbered "2". I'm sooo
close. :)
|