source: mauRepo/NewmoonJSP/src/main/webapp/WEB-INF/rules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/modules/module-dbase-functions.xq @ 7841

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/NewmoonJSP/src/main/webapp/WEB-INF/rules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/modules/module-dbase-functions.xq@7841
Revision 7841, 2.3 KB checked in by mnagni, 10 years ago (diff)
Line 
1(:
2        Library module for database functions.
3
4        #Update:        2009-08-11
5        #Author:        Pavel Golodoniuc
6        #Note:          Ported to eXist v1.2.x (production release).
7:)
8
9module namespace mod-db = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:dbase";
10
11import module namespace mod-co = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:constants"
12at "xmldb:exist:///db/modules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/module-constants.xq";
13
14declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
15
16declare variable $mod-db:base-collection-res as xs:string := "conformance-test";
17declare variable $mod-db:base-collection-name as xs:string := concat($mod-db:base-collection-res, "/", $mod-co:suite-id);
18declare variable $mod-db:mapping-collection-name as xs:string := "mapping";
19
20
21declare function mod-db:base-collection-uri($root-collection-path as xs:string) as xs:string
22{
23        concat($root-collection-path, "/", $mod-db:base-collection-res, "/", $mod-co:suite-id)
24};
25
26declare function mod-db:create-base-collection($root-collection-path as xs:string) as xs:string
27{
28        if (xmldb:collection-exists($mod-db:base-collection-name)) then
29                let $a := xmldb:remove($mod-db:base-collection-name),
30                        $c := xmldb:create-collection($root-collection-path, $mod-db:base-collection-name)
31                return "Deleted existing base collection and created a new collection."
32    else
33                let $base-coll := xmldb:create-collection($root-collection-path, $mod-db:base-collection-name)
34                return "No existing base collection detected. Created a new collection."
35};
36
37declare function mod-db:create-mapping-collection($root-collection-path as xs:string) as xs:string
38{
39        let $c := xmldb:create-collection(mod-db:base-collection-uri($root-collection-path), $mod-db:mapping-collection-name)
40        return "Created a new mapping collection."       
41};
42
43declare function mod-db:get-mapping-collection() as xs:string
44{
45        concat($mod-db:base-collection-name, "/", $mod-db:mapping-collection-name)
46};
47
48declare function mod-db:store-mapping-doc($doc-node as node(), $doc-name as xs:string)
49{
50        xmldb:store(concat($mod-db:base-collection-name, "/", $mod-db:mapping-collection-name), $doc-name, $doc-node)
51};
52
53declare function mod-db:update-mapping-collection($xupdate as node())
54{
55        xmldb:update(mod-db:get-mapping-collection(), $xupdate)
56};
Note: See TracBrowser for help on using the repository browser.