From: Wolfgang <wol...@gm...> - 2007-11-04 20:45:59
|
> My question is: How does one get a list of collections from XQuery or > should I use something besides XQuery to get collection lists? No, you can use eXist's XQuery extension functions to access collections. I just wrote a little javascript dialog to select a resource in the db. The server side code looks like this: declare function ajax:display-collection($collection as xs:string) as element()* { ( if ($collection ne '/db') then <item> <name>..</name> <type>collection</type> <path>{replace($collection, "/[^/]*$", "")}</path> </item> else (), for $child in xdb:get-child-collections($collection) order by $child return <item> <name>{$child}</name> <type>collection</type> <path>{concat($collection, '/', $child)}</path> <mime></mime> <size></size> </item>, for $child in xdb:get-child-resources($collection) order by $child return <item> <name>{$child}</name> <type>resource</type> <path>{concat($collection, '/', $child)}</path> <mime>{xdb:get-mime-type(xs:anyURI(concat($collection, '/', $child)))}</mime> <size>{fn:ceiling(xdb:size($collection, $child) div 1024)}</size> </item> ) }; let $collection := request:get-parameter("collection", ()) return <ajax-response> { ajax:display-collection($collection) } </ajax-response> Wolfgang |