[xsl] sorting titles w stopwords but w/o value in every title node

Subject: [xsl] 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
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