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

XSLT sorting for index alphabetization

Subject: XSLT sorting for index alphabetization
From: "David Sewell dsewell@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Jun 2014 21:05:48 -0000
 XSLT sorting for index alphabetization
Recently I needed to merge several back-of-the-book indexes that were marked up in XML. After experimenting a bit, I decided that given an appropriate collation, the following sequence of (XSLT 3.0) xsl:sort instructions was an adequate approximation of what indexers call the "letter-by-letter" style of alphabetizing:

<xsl:sort select="replace(., '[\s\p{P}-[(,]]', '') ! replace(., ',.*|\(.*','')"/>
<xsl:sort select="matches(., '^[^(]+,')"/>
<xsl:sort select="replace(., '[\s\p{P}-[(,]]+', '')"/>

If anyone wants to test it out with the examples that are used in the Chicago Manual of Style to illustrate the system, I've put the full script, data, and relevant chunk of the CMS up here: http://lister.ei.virginia.edu/~drs2n/alpha/ . (Suggested refinements/improvements would be welcome.)

I spent a bit of time trying to figure out how one might implement the word-by-word system (described at the above URL) using xsl:sort, but I'm not sure it's possible--it seems that word-by-word would require a full-blown recursive sorting routine. I'm happy to be proven wrong, though, by anyone who has tackled this before or is cleverer than I am about such things.

David

--
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 400314, Charlottesville, VA 22904-4314 USA
Email: dsewell@xxxxxxxxxxxx   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/

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.