xsl-list
[Top] [All Lists]

[xsl] Sorting under for-each-group

2006-08-08 06:56:09
The Stylesheet below does most of what I want -- It groups all of the
entries for a single Subject under a single subject heading. I would like to
subsort under each group (Subject) first by author then by title, and if
possible, when there is/are no author/authors, by title alone. The example would put the Kolar book first, then the Siegar Book, both under the single heading "Catalogs. Austria".

I have spent a lot of time on it but have not been able to solve the sort
within groupings problem. Can someone help?
stylesheet and xml input sample below

Thanks,
Mark

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
<xsl:template match="/">
   <List>
       <xsl:for-each-group select="/List/Entry" group-by="Subject">
       <Entry>
           <xsl:copy-of select="Subject"/>
           <xsl:for-each select="current-group()">
               <Item>
               <xsl:copy-of select="*[not(self::Subject)]"/>
               </Item>
           </xsl:for-each>
           </Entry>
       </xsl:for-each-group>
   </List>
</xsl:template>
</xsl:stylesheet>

--------------------------------
- <List>
   - <Entry>
         <Subject>Catalogs. Austria</Subject>
         <Author>Sieger, Hermann Walter</Author>
       - <Book>
             <Title>Zeppelinpost spezial-katalog</Title>
         </Book>
   -  </Entry>
   - <Entry>
     <Subject>Catalogs. Austria</Subject>
     <Author>Kolár, Hugo</Author>
   - <Book>
         <Title>Katalog známok Rakúsko 1850-1918</Title>
     <Edition>Second</Edition>
     </Book>
     </Locator>
 </Entry>
</List>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>