|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] grouping confusion
As I've reworked my stylesheets, I've gotten stuck on some code that was previously working. It formats a citation by doing a multi-level grouping and sorting by author and then year. If there is more than one author, only the first should be printed. Likewise, if there's more than one author-year combination, then only the suffix gets printed. Example: (Thrift, 1990; Tilly, 2000a, 2002b; Times, 2001) .... or (Thrift, 1990; Tilly, 1999a, b; Times, 2001) However, I'm getting this for the first one: (Thrift, 1990; Tilly, 2000a, Tilly, 2002b; Times, 2001) It's clear the problem is in how I'm using the position() function within the groups, but I can't figure out how to fix it. I suspect it may be something about the bibref variable. In the previous approach, I had used a key for that indexed all the bibliographic records by their ID attribute, while here I'm just accessing a variable that holds all those records. Is there something different conceptually about the two approaches that would cause position() to behave differently in this context? <xsl:template match="db:citation">
<!-- store citation for future use -->
<xsl:variable name="citation" select="."/>
<xsl:variable name="idref" select="db:biblioref/@linkend"/>
<xsl:variable name="bibref"
select="$enhanced-biblist/mods:modsCollection/mods:mods[@ID=$idref]"/>
<xsl:value-of select="$style-citation/cs:prefix"/>
<xsl:choose>
<xsl:when test="$citeclass='author-year'">
<xsl:for-each-group select="$bibref"
group-by="bib:grouping-key(.)">
<xsl:sort select="current-grouping-key()"/>
<xsl:for-each-group select="current-group()"
group-by="bib:year">
<xsl:sort select="current-grouping-key()"/>
<xsl:variable name="position" select="position()"/>
<xsl:for-each select="current-group()">
<a href="#{@ID}">
<xsl:if test="position() = 1">
<xsl:choose>
<xsl:when test="mods:name">
<xsl:apply-templates select="mods:name"
mode="short"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="bib:noname-substitute"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of
select="$style-citation/cs:entry/cs:creator/cs:suffix"/>
<xsl:value-of select="bib:year"/>
</xsl:if>
<xsl:apply-templates select="bib:key"/>
<!--+ ==============================================================
| render point citation details if present
+-->
<xsl:if test="$citation/db:biblioref/@begin">
<xsl:value-of
select="$style-citation/cs:entry/cs:point/cs:prefix"/>
<xsl:value-of select="$citation/db:biblioref/@begin"/>
<xsl:if test="$citation/db:biblioref/@end">
<xsl:text></xsl:text>
<xsl:value-of
select="bib:number-condense($citation/db:biblioref/@begin,
$citation/db:biblioref/@end)"/>
</xsl:if>
</xsl:if>
</a>
</xsl:for-each>
<xsl:if test="$position != last()">, </xsl:if>
</xsl:for-each-group>
<xsl:if test="position() != last()">
<xsl:value-of select="$style-citation/cs:entry/@delimiter"/>
</xsl:if>
</xsl:for-each-group>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$style-citation/cs:prefix"/>
<xsl:for-each select="db:biblioref">
<xsl:variable name="linkend" select="@linkend"/>
<xsl:variable name="number">
<xsl:choose>
<xsl:when test="$sort_order-bib='cited'">
<xsl:value-of
select="$cite-position/bib:refs/bib:unique/bib:ref[@key=$linkend]/
@position"/>
</xsl:when>
<xsl:when test="$sort_order-bib='citekey'">
<xsl:value-of select="$linkend"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="$formatted-biblist/xhtml:p[@id=$linkend]/xhtml:
span[@class='mark']"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="#{$linkend}">
<xsl:value-of select="$number"/>
</a>
<xsl:if test="position() != last()">, </xsl:if>
<xsl:if test="position() != last()">
<xsl:value-of select="$style-citation/cs:entry/@delimiter"/>
</xsl:if>
</xsl:for-each>
<xsl:value-of select="$style-citation/cs:suffix"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$style-citation/cs:suffix"/>
</xsl:template>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








