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

Re: groupi-by statements?

Subject: Re: groupi-by statements?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Thu, 26 Aug 2004 11:50:59 -0400
bruce d arcus miami
I need to repeat this question:

My 2.o stylesheet has a function it uses to group records based on author.

However, the grouping and sorting problem is more complex than this, and is based on the following rule:

1) use author-name string
2) if there is no author name:
a. when dealing with a periodical, use the periodical title in place of the author name
b. otherwise use "anonymous"


So, in other words, if I have a magazine article from Newsweek, it would sort and format like so:

Newsweek (2000) Article Title ....

Currently, it incorrectly does this:

(2000) Article Title ....

Here's my current code:

<xsl:function name="bib:grouping-key" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)" />
<xsl:choose>
<xsl:when test="$bibref/mods:name">
<xsl:value-of separator=";">
<xsl:for-each select="$bibref/mods:name">
<xsl:value-of
select="string-join((mods:namePart[@type = 'family']|
mods:namePart[not(@type)],
mods:namePart[@type = 'given']), ',')" />
</xsl:for-each>
</xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- test to see if we have a periodical article -->
<xsl:when test="$bibref/mods:relatedItem[@type='host']/mods:issuance = 'continuing'">
<xsl:for-each select="$bibref">
<!-- use periodical title -->
<xsl:value-of select="mods:relatedItem[@type='host']/mods:titleInfo[not(@type)]/mods: title"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:text>Anonymous</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:function>


The main bib template then just calls the function like so:

    <xsl:for-each-group select="$bibref" group-by="bib:grouping-key(.)">
      <xsl:sort select="current-grouping-key()"/>

What have I done wrong, and how do I fix it?

Bruce


-- Bruce D'Arcus, PhD Miami University 216 Shideler Hall Oxford, OH 45056 513-529-1521

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.