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

sorting titles w stopwords but w/o value in every titl

Subject: sorting titles w stopwords but w/o value in every title node
From: "Susan Campbell" <SCampbell@xxxxxxxxxxxxxx>
Date: Thu, 26 Aug 2004 17:24:39 -0400
xsl sort concat
Greetings,
Thanks for the examples on this list.  They've been very helpful, but I'm
stuck now. I would greatly appreciate some help, pointers or a push in a
different/successful direction.

Is it possible to sort by title ignoring stopwords and return all nodes if not
every entry has a title? I need to sort the titles ignoring initial words "a,
an & the".  I then need to output each item in title sort order, keeping the
doc-numbers together.  I also need a secondary sort by arrival date.

My xml, which I cannot change, often follows this pattern:

<section-02>
<title>Forbes.</title>
<isbn-issn>0015-6914</isbn-issn>
<doc-number>58615</doc-number>
<description>v.173:no.5(2004:Mar.15)</description>
<arrival-date>03/15/2004</arrival-date>
</section-02>

<section-02>
<title></title>
<isbn-issn-code></isbn-issn-code>
<doc-number>58615</doc-number>
<description>v.173:no.1(2004:Jan. 12)</description>
<arrival-date>01/12/2004</arrival-date>
</section-02>

<section-02>
<title></title>
<isbn-issn-code></isbn-issn-code>
<doc-number>58615</doc-number>
<description>v.173:no.2(2004:Feb. 02)</description>
<arrival-date>01/21/2004</arrival-date>
</section-02>


My xsl looks like this:

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
   xmlns:sw="mailto:me@xxxxxxx";
   exclude-result-prefixes="sw">
<sw:stop>
	<word>the</word>
	<word>a</word>
	<word>an</word>
</sw:stop>
<xsl:variable name="stop-words"
select="document('')/xsl:stylesheet/sw:stop/word"/>
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUV'"/>
<xsl:template match="/">
<result>
<table border="'1'">
	<th colspan="6">Arrived Issues sorted without stop words</th>
	<tr>
	<td align="center"><b/>number</td>
	<td align="center"><b/>Title</td>
	<td align="center"><b/>ISBN-ISSN</td>
	<td align="center"><b/>Imprint</td>
	<td align="center"><b/>Description</td>
	<td align="center"><b/>Arrived</td></tr>
	<!-- sort works but then cannot get items w/o titles nor sort the dates
			<xsl:for-each select="//section-02/title[text()!='']">
			<xsl:sort select="concat(substring(substring-after(.,' '), 0 div boolean
			($stop-words[starts-with(translate(current(), $uppercase, $lowercase),
			concat(translate(., $uppercase, $lowercase), ' '))])), substring(., 0 div
not
			($stop-words[starts-with(translate(current(), $uppercase, $lowercase),
			concat(translate(., $uppercase, $lowercase), ' '))])))"/>
			-->
	<!-- doesn't work here, but works without the predicate and /title if each
record has a title
			<xsl:for-each select="//section-02">
			<xsl:sort select="concat(substring(substring-after(title[text()!='',' '), 0
div boolean
			($stop-words[starts-with(translate(current()/title, $uppercase,
$lowercase),
			concat(translate(., $uppercase, $lowercase), ' '))])),
substring(title[text()!='', 0 div not
			($stop-words[starts-with(translate(current()/title, $uppercase,
$lowercase),
			concat(translate(., $uppercase, $lowercase), ' '))])))"/>
			-->
	<!-- secondary sort -->
			<xsl:for-each select="//section-02">
			<xsl:sort select="number(concat(substring(arrival-date, 7,4),
			substring(arrival-date, 1,2), substring(arrival-date, 4,2)))"
order="descending"/>
	<tr>
	<td width="10%"><xsl:value-of select="doc-number"/></td>
	<td width="30%"><xsl:value-of select="title" /></td>
	<td width="10%"><xsl:value-of select="isbn-issn"/></td>
	<td width="20%"><xsl:value-of select="imprint"/></td>
	<td width="20%"><xsl:value-of select="description"/></td>
	<td width="10%"><xsl:value-of select="arrival-date"/></td>
	</tr>
	</xsl:for-each>
</table>
</result>
</xsl:template>
</xsl:stylesheet>

Thank you very much,
Susan Campbell
College Center for Library Automation
1753 W. Paul Dirac Drive
Tallahassee, FL 32310
850-922-6044

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.