[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Urgent Help Needed in XSLT

Subject: RE: Urgent Help Needed in XSLT
From: "Marrow" <marrow@xxxxxxxxxxxxxx>
Date: Fri, 20 Sep 2002 23:16:12 +0100
topxml xsl sort
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.