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

comparing strings

Subject: comparing strings
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 2 Jan 2001 10:28:29 +0100 (MET)
comparing strings
Dear friends,

happy new year to everybody!

Is there someone out there who can answer my simple question:
How to compare strings with XPath/XSLT, something like strcmp() in C
or compareTo() in Java?
I want a pure XSLT solution without using extensions.

For those of you who are interested I have a little use case:

Consider this simplified dictionary:
<longman>
   ...
   <term>oz</term>
   <term>ozone</term>
   <term>p</term>
   <term>pa</term>
   <term>pace</term>
   <term>pacemaker</term>
   <term>pacesetter</term>
   <term>pachyderm</term>
   <term>pacific</term>
   <term>pacifier</term>
   <term>pacifism</term>
   <term>pacifist</term>
   <term>pacify</term>
   <term>pack</term>
   <term>package</term>
   <term>packaged</term>
   <term>packaging</term>
   <term>packed</term>
   <term>packer</term>
   <term>packet</term>
   <term>packing</term>
   <term>pact</term>
   <term>pad</term>
   ...
</longman>

Question: given an arbitrary input term (e.g. as a parameter), how
can I display the next 10 terms, starting with my input or the
term which would follow directly in alphabetical order?

If I had numbers instead of strings, the following template would
solve the required task:

<xsl:param name="input" />

<xsl:template match="term">
   <xsl:if test=". >= $input and
                 not(preceding-sibling::term[10] >= $input)">
      <!-- display . in some appropriate way -->
   </xsl:if>
</xsl:template>

Regards,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/

 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.