RE: [xsl] Urgent Help Needed in XSLT

Subject: RE: [xsl] Urgent Help Needed in XSLT
From: "Marrow" <marrow@xxxxxxxxxxxxxx>
Date: Fri, 20 Sep 2002 23:16:12 +0100
Hi Yan,

Do you mean something like Google groups does?

Try this (not sure if it does what you want)...

== XSL ====================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" indent="yes"/>
<xsl:key name="kDistinctTopic" match="/livelink//llnode"
use="ancestor-or-self::llnode[last()]/@name"/>
<xsl:template match="livelink">
  <!-- create a list of (node ids) for each distinct topic -->
  <!-- with the id of the latest message in that thread   -->
  <xsl:variable name="sorted-topic-dates">
    <!-- find the distinct topics -->
    <xsl:for-each select=".//llnode[generate-id() =
generate-id(key('kDistinctTopic',ancestor-or-self::llnode[last()]/@name)
)]">
      <!-- sort this and descendant children by their descending date
-->
      <xsl:for-each select="descendant-or-self::llnode">
        <xsl:sort select="@created" order="descending"/>
        <!-- output a reference to this node if it the latest in this
'thread' -->
        <xsl:if test="position() = 1">
          <xsl:text>|</xsl:text>
          <xsl:value-of select="generate-id()"/>
        </xsl:if>
      </xsl:for-each>
    </xsl:for-each>
  </xsl:variable>
  <html>
    <body>
      <table>
        <!-- go through all nodes where they appear in the distinct
topic dates variable -->
        <xsl:for-each
select=".//llnode[contains($sorted-topic-dates,concat('|',generate-id())
)]">
          <!-- sort them on date descending -->
          <xsl:sort select="@created" order="descending"/>
          <!-- only show the first 10 -->
          <xsl:if test="position() &lt; 11">
            <tr>
              <td>
                <xsl:value-of
select="ancestor-or-self::llnode[last()]/@name"/>
              </td>
              <td>
                <xsl:value-of select="@created"/>
              </td>
              <td>
                <xsl:choose>
                  <xsl:when test="ancestor::llnode">
                    <xsl:text> (Reply)</xsl:text>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:text> (New Topic)</xsl:text>
                  </xsl:otherwise>
                </xsl:choose>
              </td>
            </tr>
          </xsl:if>
        </xsl:for-each>
      </table>
    </body>
  </html>
</xsl:template>
</xsl:stylesheet>
== end of XSL =============================================

Hope this helps
Marrow 
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread