One remaining problem is how to collapse (Doe, 1999a; Doe, 1999c) into
(Doe, 1999a, c). Remindr, in DocBook NG, citations now look like:
Clearly the problem is something about the if test flagged below. I
would have thought the position in the current group would get me
what I want, but it doesn't. If I remove the [...] on the bibref
variable select statement, however, I can get the collapsing to
work, but I get all of the document citations.
The test you've got is:
../mods:mods[position() = 1]
This tests if the current node's parent has a <mods:mods> element
(whose position is 1 -- this will only and always be true if there's a
<mods:mods> element at all, so the test is equivalent to
"../mods:mods"). Since the current element is a <mods:mods> element,
the test is guaranteed to be true.
What you want is simply:
<xsl:if test="position() = 1">
This tests whether the current <mods:mods> element is the first within
the group of <mods:mods> elements that you're looking at.
By the way, you really should be using a key rather than doing:
Declare it like:
<xsl:key name="mods" match="mods:mods" use="@ID" />
and use it like:
<xsl:variable name="bibref" select="key('mods', $idref)" />
Keys are much faster and neater than searching through the entire
document using a predicate. If you rather use a predicate, at least
limit the search by using an explicit path down to the <mods:mods>
elements rather than searching the entire document with //mods:mods.