source: mauRepo/newmoon/src/test/resources/rules/schema-encoding/xmi11ea/modules/module-dbase-functions.xq @ 7939

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/newmoon/src/test/resources/rules/schema-encoding/xmi11ea/modules/module-dbase-functions.xq@7939
Revision 7939, 3.2 KB checked in by mnagni, 9 years ago (diff)

Simplified the ZIP structure.
Fixed a major problem on encode process 002
Promoted to 1.1.2

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:schema-encoding:xmi11ea:dbase";
10
11import module namespace mod-co="urn:local-module:schema-encoding:xmi11ea:constants"
12at "xmldb:exist:///db/modules/schema-encoding/xmi11ea/module-constants.xq";
13
14declare namespace xmldb="http://exist-db.org/xquery/xmldb";
15
16declare variable $mod-db:base-collection-res as xs:string := "schema-encoding";
17declare variable $mod-db:base-collection-name as xs:string := concat($mod-db:base-collection-res, "/", $mod-co:suite-id);
18declare variable $mod-db:working-collection-name as xs:string := "working";
19declare variable $mod-db:mapping-collection-name as xs:string := "mapping";
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-working-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:working-collection-name)
40    return "Created a new working collection."       
41};
42
43declare function mod-db:create-mapping-collection($root-collection-path as xs:string) as xs:string
44{
45    let $c := xmldb:create-collection(mod-db:base-collection-uri($root-collection-path), $mod-db:mapping-collection-name)
46    return "Created a new mapping collection."       
47};
48
49declare function mod-db:get-working-collection()
50{
51    concat($mod-db:base-collection-name, "/", $mod-db:working-collection-name)
52};
53
54declare function mod-db:get-working-collection-as-nodeset()
55{
56    collection(concat($mod-db:base-collection-name, "/", $mod-db:working-collection-name))
57};
58
59declare function mod-db:get-mapping-collection()
60{
61    concat($mod-db:base-collection-name, "/", $mod-db:mapping-collection-name)
62};
63
64declare function mod-db:store-working-doc($doc-node as node(), $doc-name as xs:string)
65{
66    xmldb:store(concat($mod-db:base-collection-name, "/", $mod-db:working-collection-name), $doc-name, $doc-node)
67};
68
69declare function mod-db:store-mapping-doc($doc-node as node(), $doc-name as xs:string)
70{
71    xmldb:store(concat($mod-db:base-collection-name, "/", $mod-db:mapping-collection-name), $doc-name, $doc-node)
72};
73
74declare function mod-db:update-working-collection($xupdate as node())
75{
76    xmldb:update(mod-db:get-working-collection(), $xupdate)
77};
78
79declare function mod-db:update-mapping-collection($xupdate as node())
80{
81    xmldb:update(mod-db:get-mapping-collection(), $xupdate)
82};
Note: See TracBrowser for help on using the repository browser.