Altova Mailing List Archives


RE: [xsl] groupi-by statements?

From: "Michael Kay" <mhk@--------->
To:
Date: 8/26/2004 4:52:00 PM
The obvious answer is there's an error in your path expression, but it's
hard to identify it without having the source document handy.

Michael Kay 

> -----Original Message-----
> From: Bruce D'Arcus [mailto:bdarcus@xxxxxxxxxxxxx] 
> Sent: 26 August 2004 16:51
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] groupi-by statements?
> 
> 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(@typ
> e)]/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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.