From: Wolfgang M. M. <wol...@us...> - 2004-08-10 20:34:26
|
Update of /cvsroot/exist/eXist-1.0/webapp/mods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26376/webapp/mods Modified Files: overview.xq config.xqm Log Message: MODS metadata demo application (to be continued). Index: config.xqm =================================================================== RCS file: /cvsroot/exist/eXist-1.0/webapp/mods/config.xqm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** config.xqm 22 Jul 2004 19:00:48 -0000 1.2 --- config.xqm 10 Aug 2004 20:34:14 -0000 1.3 *************** *** 2,5 **** --- 2,6 ---- declare namespace mods="http://www.loc.gov/mods/v3"; + declare namespace util="http://exist-db.org/xquery/util"; (: the base URI for the chiba servlet :) *************** *** 10,14 **** declare variable $c:detailsXsl { "styles/mods-detailed.xsl" }; ! declare variable $c:css { "styles/default-style.css" }; (: called to select elements from a record for display :) --- 11,15 ---- declare variable $c:detailsXsl { "styles/mods-detailed.xsl" }; ! declare variable $c:css { "styles/display.css" }; (: called to select elements from a record for display :) *************** *** 23,26 **** --- 24,53 ---- }; + declare function c:orderByName($m as element()) as xs:string? + { + let $name := $m/mods:name[1], + $order := + if($name/mods:namePart[@type='family']) then + concat($name/mods:namePart[@type='family'], ", ", $name/mods:namePart[@type='given']) + else if($name/mods:namePart) then + xs:string($name/mods:namePart) + else + "" + return + (util:log("debug", $order), + $order) + }; + + (: Map order parameter to xpath for order by clause :) + declare function c:orderExpr($field as xs:string) as xs:string + { + if ($field = "creator") then + "c:orderByName($m)" + else if ($field = "title") then + "$m/m:titleInfo[1]/m:title[1]" + else + "$m/m:originInfo/m:dateCreated[1] descending" + }; + declare function c:sidebar($url as xs:string) { Index: overview.xq =================================================================== RCS file: /cvsroot/exist/eXist-1.0/webapp/mods/overview.xq,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** overview.xq 22 Jul 2004 19:00:48 -0000 1.2 --- overview.xq 10 Aug 2004 20:34:14 -0000 1.3 *************** *** 23,27 **** else ( <p>Removing document {$doc} from collection {$path}.</p>, ! let $collection := xmldb:collection(concat("xmldb:exist://", $path), $user, $pass) --- 23,27 ---- else ( <p>Removing document {$doc} from collection {$path}.</p>, ! let $collection := xmldb:collection(concat("xmldb:exist://", $path), $user, $pass) *************** *** 48,62 **** }; - (: Map order parameter to xpath for order by clause :) - declare function b:orderExpr($field as xs:string) as xs:string - { - if ($field = "creator") then - "$m/m:name[1]/m:namePart[@type='family'],$m/m:name[1]/m:namePart[@type='given']" - else if ($field = "title") then - "$m/m:titleInfo[1]/m:title" - else - "$m/m:originInfo/m:dateIssued[1] descending" - }; - (: Create an XPath expression for the current field and search terms :) declare function b:createXPath($user as xs:string, $terms as xs:string) --- 48,51 ---- *************** *** 121,127 **** declare function b:buildQuery($xpath as xs:string, $order as xs:string) as xs:string { ! let $orderExpr := b:orderExpr($order) return ! concat("for $m in ", $xpath, " order by ", $orderExpr, " return $m") }; --- 110,119 ---- declare function b:buildQuery($xpath as xs:string, $order as xs:string) as xs:string { ! let $orderExpr := c:orderExpr($order) return ! concat( ! "import module namespace c='http://exist-db.org/modules/mods-config' ! at 'config.xqm'; ! for $m in ", $xpath, " order by ", $orderExpr, " return $m") }; |