Maintenance

  • Home
  • Log in
  • « Update eXist DB script
  • Getting rid of .svn dirs in a tree »

XQuery for retrieving the latest modified date of any resource in a collection

Posted by mholmes on 21 Dec 2011 in R & D, Activity log, Documentation, Documentation

We intend this as the first stage in implementing a script which can refresh a large db collection based on document dates, so only documents changed since the last-modified date are uploaded (perhaps after allowing a 24-hour cushion):

xquery version "1.0";

declare namespace local="http://hcmc.uvic.ca/ns";
declare namespace exist="http://exist.sourceforge.net/NS/exist";
declare namespace xmldb="http://exist-db.org/xquery/xmldb";
import module namespace request="http://exist-db.org/xquery/request";


declare variable $inCol := request:get-parameter("col", "/db");
declare variable $startCol := if (starts-with($inCol, "/")) then $inCol else concat("/", $inCol);

declare function local:getLatest($col as xs:string) as xs:dateTime*
{
	let $dates :=local:getDocDates($col)
	return max($dates)
};

declare function local:getDocDates($col as xs:string) as xs:dateTime*
{
	let $result :=
		(for $c in xmldb:get-child-collections($col) return local:getDocDates(concat($col, '/', $c)),
        for $r in xmldb:get-child-resources($col) return xmldb:last-modified($col, $r)
        )
	return $result
};

local:getLatest($startCol)
UPDATE: the next step is ready. See this post: http://hcmc.uvic.ca/blogs/index.php?blog=11&p=8962
This entry was posted by Martin and filed under R & D, Activity log, Documentation, Documentation.

Maintenance

This blog is the location for all work involving software and hardware maintenance, updates, installs, etc., both routine and urgent.
  • Home
  • Recently
  • Archives
  • Categories

Search

Categories

  • All
  • Announcements
  • Hit by a bus
  • Labs
    • Activity log
    • Documentation
  • Notes
  • R & D
    • Activity log
    • Documentation
  • Servers
    • Activity log
    • Documentation
  • Tasks

All blogs

  • Academic
  • AdaptiveDB
  • Admin
  • Announcements
  • CanMys
  • Cascade
  • CGWP
  • ColDesp
  • Depts
  • DVPP
  • Endings
  • HCMC Blogs
  • Landscapes
  • LEMDO
  • Linguistics
  • Maint
  • LondonMap
  • Mariage
  • MoM
  • Moses
  • Pro-D
  • Projects
  • ScanCan
  • HumsSites
  • Wendat

This collection ©2022 by admin • Help • b2evolution