[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Muench method for two or three keys? (Sorting and
Tempore 05:00:33, die 01/16/2005 AD, hinc in
xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Daniel O'Donnell
<daniel.odonnell@xxxxxxxx>:
So what I need is a sheet that does the following: Hi, I don't think you can use muenchian grouping for more than 1 level of grouping (could be wrong). The following method starts with the muenchian method, but uses another algorithm for deeper hierarchy levels (the subfields). The stylesheet is not memory-friendly but it does output what you want: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:key name="headkey" match="record" use="head"/> <xsl:key name="sub1" match="subfield1" use="../head"/> <xsl:key name="sub2" match="subfield2" use="../subfield1"/> <xsl:template match="index"> <index> <xsl:apply-templates select="record[generate-id(.)=generate-id(key('headkey', head)[1])]/head"> <xsl:sort select="."/> </xsl:apply-templates> </index> </xsl:template> <xsl:template match="head"> <item><xsl:value-of select="."/> <xsl:if test="count(key('sub1', .)[text()])>0"> <list> <xsl:apply-templates select="key('sub1', .)[not(../preceding::record[head=current()]/subfield1=.)]"> <xsl:sort select="."/> </xsl:apply-templates> </list> </xsl:if> </item> </xsl:template> <xsl:template match="subfield1[text()]"> <item><xsl:value-of select="."/> <xsl:if test="count(key('sub2', .)[text()])>0"> <list> <xsl:apply-templates select="key('sub2', .)[not(../preceding::record[subfield1=current()]/subfield2=.)]"> <xsl:sort select="."/> </xsl:apply-templates> </list> </xsl:if> <xsl:if test="count(key('sub2', .)[text()])=0"> <xsl:apply-templates select="../locater"/> </xsl:if> </item> </xsl:template> <xsl:template match="subfield2[text()]"> <item><xsl:value-of select="."/> <xsl:apply-templates select="../locater"/> </item> </xsl:template> <xsl:template match="locater"> <xsl:if test="string-length()!=0"> <xsl:text>, </xsl:text> <seg type="locater"> <xsl:value-of select="."/> </seg> </xsl:if> </xsl:template> </xsl:stylesheet> regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Vincit omnia simplicitas Keep it simple
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|