[xsl] How to correctly apply Dimitre' generic sort template

Subject: [xsl] How to correctly apply Dimitre' generic sort template
From: "Yang" <sfyang@xxxxxxxxxxxxx>
Date: Tue, 10 Jul 2001 18:05:10 +0800
Hi, Dimitre,

I try to work out an exercise to apply your generic sort, and  need your
kind help to show what I have missed in the xsl below.

What I am doing is to apply your example shown in vbxml.com,
which can bring the last result from using named mergeSingleNode once,
and the template mergeSingleNode and binSearch from
This modification did not bring me a desired solution as below.
        19321004 19530323 19920714 19990417 20100714
This is the set from sorting the first five nodes, from all 10 nodes.

Besides, can you show to do following things:

1.  How to define comparison mode > or < using comparisonSelector variable?
    Your coding using gt1 and gt2 variable to define comparisonSelector
    I can not see any difference between these two.

2.  How to select the ascending or desending option for the given number of
    Reading through the coding I have difficulty in locating a piece of
    doing these things.

  I see the  generic sort can help me a lot in solving practical cases.
  Thanks for any of your help in advance.

**   xsl listing  **

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:gt1="gt1"
xmlns:gt2="gt2" exclude-result-prefixes="gt1 gt2">
  <gt1:gt1 />
  <gt2:gt2 />
  <xsl:include href="genericSearchSort.sort.template.xsl" />
  <xsl:output method="text" />
  <xsl:variable name="gt1-Node" select="document('')/*/gt1:*[1]" />
  <xsl:variable name="gt2-Node" select="document('')/*/gt2:*[1]" />
  <xsl:template match="/">
  <xsl:variable name="theNodes" select="/dates/datesUnSorted/date" />
  <xsl:variable name="cntNodes" select="count($theNodes)" />
  <xsl:variable name="posLength" select="string-length($cntNodes)" />
  <xsl:variable name="comparisonSelector" select="$gt1-Node" />
  <xsl:variable name="theBuffer">
  <xsl:for-each select="$theNodes[position() < 6]">
  <xsl:sort select="@value" />
  <xsl:value-of select="concat(@value,' ')" />
 <!--  $theResult will hold the result   -->
 <xsl:variable name="theResult">
 <xsl:call-template name="mergeSingleNode">
  <xsl:with-param name="theSiblings" select="$theNodes" />
  <xsl:with-param name="siblPosition" select="6" />
  <xsl:with-param name="sortPad" select="$theBuffer" />
  <xsl:with-param name="posLength" select="$posLength" />
  <xsl:with-param name="gtTypeNode" select="$comparisonSelector" />
  <xsl:value-of select="$theResult" />

Sun-Fu Yang

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

Current Thread