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

RE: alpha comparison

Subject: RE: alpha comparison
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 10 Apr 2000 10:38:47 +0100
xslt string order comparison
> I need to check if the following-sibling has
> a child with content <tba> than the current node.
> Its a security check to ensure that the input file is
> in sorted order (No I won't say why, its too
> embarassing).
>
There's no operator to do alphabetic order comparison, the only thing that
does it is xsl:sort.

The simplest way to check that a list of strings is in sorted order is to
sort it and see if the output equals the input. It's probably possible to
improve the following:

<xsl:template name="is-sorted">
   <!-- test whether the document-order of the supplied $nodes 
        is the same as the sorted order of their string-values -->
   <xsl:param name="nodes"/>
   <xsl:variable name="unsorted-nodes">
      <xsl:for-each select="$nodes"/>
          <xsl:value-of select="."/>
      </xsl:for-each>
   </xsl:variable>
   <xsl:variable name="sorted-nodes">
      <xsl:for-each select="$nodes"/>
          <xsl:sort/>
          <xsl:value-of select="."/>
      </xsl:for-each>
   </xsl:variable>
   <xsl:if test="string($sorted-nodes) != string($unsorted-nodes)">
      <xsl:message terminate="yes">Data is not correctly
sorted</xsl:message>
   </xsl:if>
</xsl:template>


 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.