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

Re: sorting a list of titles after removal of stopword

Subject: Re: sorting a list of titles after removal of stopwords and special characters
From: Trevor Nash <tcn@xxxxxxxxxxxxx>
Date: Tue, 11 Dec 2001 10:14:28 +0000
remove stopword
>I am trying to sort a list of titles that have been processed using XSLT to
>remove all leading articles (stopwords "A", "An", and "The"), and to remove
>special characters such as  [,  ], ^, and so on.
>
><B>Sorted: </B><P />
><xsl:apply-templates select="//ead/book/title" mode="with-stoplist">
><xsl:sort select="$stoplist" order="descending"/>
></xsl:apply-templates>
>
One problem is that you are using an expresion in "xsl:sort select"
which does not depend on the context node: its just a global variable.
You are saying all the records have the same key, so they will just
come out in document order.

What you need is an expression that, given the context of a title
element, will return a string containing the edited title (stop words
removed).  This cannot be done with standard XSLT, but you have three
possibilities:
   1) You are using Saxon, which has an extension saxon:function
    which lets you write a function in XSLT - more or less the
    contents of your mode="with-stoplist" template.
   2) Do the transform in two phases: first add an attribute to each
     title containing the edited form, then do a sort on this
     attribute.  If you use the node-set extension you can do
     this in one transformation, otherwise you need two.
  3) If you want 100% XSLT 1.0 then use Dimitri's generic sort
     library:  find this through the list archive.  This doesn't sort
     using xsl:sort, so avoids the problem of cramming the 
     stop list deletion function into an XPath expression.

Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 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.