xsl-list
[Top] [All Lists]

Re: sorting titles w stopwords but w/o value in every title node

2004-08-30 06:01:10
Thanks for the help. (I am still referring to the stop-words variable with 
document('')/xsl:stylesheet/sw:stop/word because that does give me the sort 
order. Because
our setup, that may be my only option.)

The problem I still have is that entries without a value in the title sort 
first.  
I need to group by title when the doc-number is the same. It may be both a 
sorting 
and grouping problem, but I don't know how to go about it.  

(The doc number is included only for testing. I left out imprint and ISBN from 
this sample for clarity. It is possible to have the same issue or different 
issue arrive on the same or different days as there are multiple subscriptions.)

The output I need is:
doc#    Title                                 Description                       
Arrived date    
53690 American Artist                   v.68:no.738(2004:Jan.)   02/26/2004
57769   The American city & country     v.119:no.1(2004:Jan.)    02/11/2004     
57769                                           v.119:no.3(2004:Mar.)    
03/25/2004
58345 American demographics             v.26:no.1(2004:Feb.)     02/05/2004
58345                                   v.26:no.1(2004:Feb.)     02/26/2004
58345                                   v.26:no.2(2004:Mar.)     02/26/2004
58345                                           v.26:no.2(2004:Mar.)     
02/26/2004

Sample of problem causing xml:
-------------
<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 stylesheet:
-------------
<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
   xmlns:sw="mailto:bubba(_at_)aol(_dot_)com"
   exclude-result-prefixes="sw">
<xsl:include href="funcs.xsl"/>
<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="/">        
<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>
<xsl:for-each select="//section-02/z13-title">
<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), ' '))])))"/>

<xsl:sort select="number(concat(substring(../z30-arrival-date, 7,4),
substring(../z30-arrival-date, 1,2), 
substring(../z30-arrival-date, 4,2)))" order="descending"/> 
                        
<tr>
<td width="10%"><xsl:value-of select="../z30-doc-number"/></td>
<td width="30%"><xsl:value-of select="../z13-title" /></td>
<td width="10%"><xsl:value-of select="../z13-isbn-issn"/></td>
<td width="20%"><xsl:value-of select="../z13-imprint"/></td>
<td width="20%"><xsl:value-of select="../z30-description"/></td>
<td width="10%"><xsl:value-of select="../z30-arrival-date"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

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