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

followup on multi-level grouping/sorting/position

Subject: followup on multi-level grouping/sorting/position
From: Bruce D'Arcus <bdarcus@xxxxxxxxx>
Date: Wed, 27 Apr 2005 20:59:03 -0400
xsl sort position
I have a followup to the thread from the other day on grouping and sorting author-year bibliographies.

I managed to integrate Michael Kay's suggestion into my (rather complicated) code, and even refined it by moving a lot of the more complex logic into a series of functions (the real world example is much more complicated than the example I posted).

I've now tried to adapt the same approach to the problem of the in-text citations, which follow the same basic rules, where output should be (Doe, 1999; Smith, 2000) or (Doe, 1999, 2000; Smith, 2001a, b). So, again: multi-level grouping and sorting, with need to pass parameters to know how to handle punctuation.

The problem is that the below code yields the following message with my sample document:

<ref id="TimesP2001a" author-year_pos="1" shorten="false"/>
<ref id="Veer1996a" author-year_pos="1" shorten="false"/>
<ref id="Tilly2000a" author-year_pos="1" shorten="false"/> *
<ref id="Tilly2002a" author-year_pos="2" shorten="true"/> *
<ref id="NW2000-0207" author-year_pos="1" shorten="false"/> *
<ref id="NW2000-0424a" author-year_pos="1" shorten="false"/> *
<ref id="Tremblay2001a" author-year_pos="1" shorten="false"/>
<ref id="Thrift1990a" author-year_pos="1" shorten="false"/>
<ref id="Tilly2000a" author-year_pos="1" shorten="false"/>

The issue is that while the author-year position is being correctly reported, the "shorten-author" parameter is not correctly reported (the ref with the id of NW2000-0424a" should have @shorten="true" because it is the second of two references in a citation with an "author" of Newsweek).

The source is DocBook NG, and so the citations look like:

<citation>
  <biblioref linkend="NW2000-0207"/>
  <biblioref linkend="NW2000-0424a"/>
</citation>

Is there something obvious I'm doing wrong here? I've spent probably five hours trying to figure this out, and haven't really made any progress.

<xsl:template match="db:citation" mode="sort_citation_author-year">
<!-- store citation for future use; not sure I need this anymore, but I did earlier -->
<xsl:variable name="citation" select="."/>
<xsl:variable name="idref" select="db:biblioref/@linkend"/>
<!-- $enhanced-biblist is a temporary tree that holds the grouped and sorted data from earlier -->
<xsl:variable name="bibref"
select="$enhanced-biblist/mods:modsCollection/mods:mods[@ID=$idref]"/>
<!-- grouping on an attribute value added in the temporary tree -->
<xsl:for-each-group select="$bibref" group-by="@bib:sort-on">
<xsl:sort select="current-grouping-key()"/>
<xsl:variable name="bibrefs-for-author-sorted-by-year"
as="element(mods:mods)*">
<xsl:perform-sort select="current-group()">
<xsl:sort select="bib:year"/>
</xsl:perform-sort>
</xsl:variable>
<xsl:variable name="first-bibref-for-author" as="element(mods:mods)"
select="$bibrefs-for-author-sorted-by-year[1]"/>
<xsl:for-each-group select="current-group()" group-adjacent="bib:year">
<xsl:variable name="author-year_group_position" select="position()"/>
<xsl:variable name="shorten-author" as="xs:boolean"
select="not(. is $first-bibref-for-author)"/>
<xsl:apply-templates select="current-group()" mode="citation_author-year">
<xsl:with-param name="local-cite-style" select="$local-cite-style"/>
<xsl:with-param name="author-year_group_position" select="position()"/>
<xsl:with-param name="shorten-author" select="$shorten-author"/>
</xsl:apply-templates>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template>


<xsl:template match="*" mode="citation_author-year">
<xsl:param name="local-cite-style"/>
<xsl:param name="author-year_group_position"/>
<xsl:param name="shorten-author"/>
<xsl:message exclude-result-prefixes="xhtml">
<ref id="{@ID}" author-year_pos="{$author-year_group_position}" shorten="{$shorten-author}"/>
</xsl:message>
<xsl:text>TEST</xsl:text>
<xsl:if test="$author-year_group_position != last()">, </xsl:if>
<xsl:if test="position() != last()">
<xsl:value-of select="$style-citation/cs:entry/@delimiter"/>
</xsl:if>
</xsl:template>


Bruce

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.