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

Sorting results by output of a conversion template

Subject: Sorting results by output of a conversion template
From: allan.mccluskey@xxxxxxxxxxxxxxxxx
Date: Fri, 9 Jan 2004 15:47:14 +1100
conversion template
Hi,

I have some sophisticated sorting to do and only a basic level of
knowledge.

Essentially, I have an element coming down called 'assignStartTime' which
holds a three-digit numeric value e.g. 181, 145, 85, 133 etc etc. Now,
these figures actually represent a time and once passed through to a
conversion template (called 'convertApptEndTime'), return a figure like
12:00pm or 3:00pm etc etc. The conversion template looks like this:

<xsl:template name="convertApptStartTime">
      <xsl:param name="node"/>

      <xsl:variable name="hour" select="number(floor((($node - 1)*5) div
60))"/>

      <!-- get transformed start time value -->
      <xsl:call-template name="convertApptStartTimeShort">
         <xsl:with-param name="node" select="$node"/>
      </xsl:call-template>

      <xsl:choose>
            <xsl:when test="$hour &gt;= 12">
                  <xsl:text>pm</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                  <xsl:text>am</xsl:text>
            </xsl:otherwise>
      </xsl:choose>
</xsl:template>

<xsl:template name="convertApptStartTimeShort">
      <xsl:param name="node"/>

      <xsl:variable name="hour" select="number(floor((($node - 1)*5) div
60))"/>
      <xsl:variable name="minute" select="number((($node - 1)*5) mod 60)"/>

      <xsl:choose>
            <xsl:when test="$hour &gt; 12">
                  <xsl:if test="$minute &gt; 9">
                        <xsl:value-of select="number($hour -
12)"/>:<xsl:value-of select="$minute"/>
                  </xsl:if>
                  <xsl:if test="$minute &lt; 10">
                        <xsl:value-of select="number($hour -
12)"/>:0<xsl:value-of select="$minute"/>
                  </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                  <xsl:if test="$minute &gt; 9">
                        <xsl:value-of select="$hour"/>:<xsl:value-of select
="$minute"/>
                  </xsl:if>
                  <xsl:if test="$minute &lt; 10">
                        <xsl:value-of select="$hour"/>:0<xsl:value-of
select="$minute"/>
                  </xsl:if>
            </xsl:otherwise>
      </xsl:choose>
</xsl:template>


I need to be able to sort my results by the output of this template.
So...is there a way using XSL:SORT to call a template (like the one above)
and sort the results that way?? e.g. I'm using xsl:for-each to run through
my XML elements and call a tableRow template which produces the HTML..
Somehow, I'd like to sort via time as noted in bold in the xsl:sort
statement below.


<xsl:for-each select="startTime">

      <xsl:sort select="OUTPUT-FROM-MY-CONVERSION-TEMPLATE"/>

      <xsl:call-template name="tableRow">
            <xsl:with-param name="pColour" select="'#EEEEFF'"/>
      </xsl:call-template>

</xsl:for-each>


I don't know if it's possible or not but many thanks for your time.

Regards
Allan







Important:  This e-mail is intended for the use of the addressee and may contain information that is confidential, commercially valuable or subject to legal or parliamentary privilege.  If you are not the intended recipient you are notified that any review, re-transmission, disclosure, use or dissemination of this communication is strictly prohibited by several Commonwealth Acts of Parliament.  If you have received this communication in error please notify the sender immediately and delete all copies of this transmission together with any attachments.


 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.