[XML4Lib] Alphabetical Listing
Engard, Nicole
nicole.engard at ptsem.edu
Fri Oct 19 09:28:23 EDT 2007
Hi all,
Just wondering if anyone has written an Xquery that will split a list up
alphabetically. In particular a list of authors/titles. I want to put
an A-Z list of links at the top of the page so people can see just the
authors with names starting with B if they way - and so on. I figured
why re-invent the wheel if someone else has done it already :-)
This is my list:
define function display-authorlist($params as node()) as node() {
(: Display introductory text :)
<span>
<h1>Alphabetical Listing of Authors</h1>
<ul>
{
(: Search creators and include total contributions :)
for $creators in fn:distinct-values(
for $creator in fn:collection()//dc:creator
let $uniformName
:=fn:normalize-space(fn:replace($creator,",.*$",""))
order by fn:tokenize($uniformName, " ")[fn:last()]
return $uniformName)
let
$count:=xdmp:estimate(/METS:mets/METS:dmdSec/METS:mdWrap/METS:xmlData/dc
:creator[cts:contains(., $creators)])
where $count != 0
return <li><a href="default.xqy?terms={$creators}">{$creators}</a>
({$count})</li>
}
</ul>
</span>
}
It's a bit insane right now without having some sort of division.
Thanks,
Nicole C. Engard
Metadata Librarian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webjunction.org/wjlists/xml4lib/attachments/20071019/a63289c7/attachment.htm
More information about the XML4Lib
mailing list