Re: [xsl] groupi-by statements?

Subject: Re: [xsl] groupi-by statements?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Fri, 20 Aug 2004 09:32:45 -0400
On Aug 18, 2004, at 11:46 AM, David Carlisle wrote:

substring(
(mods:originInfo/mods:dateIssued ,
mods:relatedItem/mods:originInfo/mods:dateIssued ,
mods:relatedItem/mods:part/mods:date )[1]
,1,4)

which would pick the first element in that sequence (as it appears in
the stylesheet) which appears in the source.

Thanks David; this is what I was looking for. A followup:


The grouping and sorting problem of which this is a part is also based on the following rule:

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


Here's how I've extended the function that Jeni came up with to handle 1, but it's not working:

<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>
<xsl:when test="$bibref/mods:relatedItem[@type='host']/mods:issuance = 'continuing'">
<xsl:for-each select="$bibref/mods:relatedItem[@type='host']/mods: titleInfo[not(@type)]">
<xsl:value-of select="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?

Bruce

Current Thread