source: exist/trunk/xquery/stubB_DPT.xq @ 3841

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/xquery/stubB_DPT.xq@4326
Revision 3841, 7.0 KB checked in by cbyrom, 12 years ago (diff)

Various updates to the xquery files - to remove usage of invalid specs
and dependency on obsolete function calls. Also add the inputParse_xquery_lib.xquery
file - referenced from the xquery files but not currently included in codebase.
NB, changes made to allow use of Saxon java library to do xqueries - to
remove the need for the discovery service eXist DB.

  • NB, also changes tested by comparing saxon transforms to eXist ones; these

were found to be identical.

Line 
1(: This query for TargetCollection, RepositoryID and LocalID, will return the stubB for a Data Production Tool, DPT :)
2declare default element namespace 'http://ndg.nerc.ac.uk/moles/dataproductiontool';
3import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery';
4(:
5Will return when scope problem sussed... ;(
6import module namespace stubblib='http://ndg.nerc.ac.uk/xquery/lib/stubb' at 'xmldb:exist:///db/xqueryLib/StubB/stubb_xquery_lib.xquery';
7:)
8declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions';
9declare namespace moles='http://ndg.nerc.ac.uk/moles';
10
11declare variable $targetCollection as xs:string := 'TargetCollection';
12declare variable $repositoryIdentifier as xs:string := 'RepositoryID';
13declare variable $localIdentifier as xs:string := 'LocalID';
14
15declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()
16(: Returns a 'stubB' style activity record to expand an activity record :)
17(: Security not implemented here yet :)
18{
19let $SRAct := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[
20moles:dgMetadataID/moles:localIdentifier=$locid
21and moles:dgMetadataID/moles:repositoryIdentifier=$repid ]
22return
23element  {$out-element-name} {
24($SRAct/moles:dgMetadataID),
25($SRAct/moles:dgMetadataDescription),
26($SRAct/moles:name),
27($SRAct/moles:abbreviation),
28($SRAct/moles:logos)
29} (: </activity> :)
30} ;
31
32declare function f:return-stub-dataentity($out-element-name as xs:string, $DE as element()) as element()
33(: Returns a 'stubB' style observation station record to expand an data entity record :)
34(: Security not implemented yet :)
35{
36let $SRDE := $DE
37return 
38element {$out-element-name} {
39($SRDE/moles:dgMetadataID),
40($SRDE/moles:dgMetadataDescription),
41($SRDE/moles:name),
42($SRDE/moles:abbreviation)
43} (: </dgDataEntity> :)       
44} ;
45
46declare function f:return-stub-dpt($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()
47(: Returns a 'stubB' style dpt record to expand a dpt record :)
48(: Security not implemented yet :)
49{
50let $SRDPT := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[
51moles:dgMetadataID/moles:localIdentifier=$locid
52and
53moles:dgMetadataID/moles:repositoryIdentifier=$repid
54]
55return 
56element {$out-element-name} {
57$SRDPT/moles:dgMetadataID,
58$SRDPT/moles:dgMetadataDescription,
59$SRDPT/moles:name,
60$SRDPT/moles:abbreviation,
61$SRDPT/moles:logos
62} (: </dataproductiontool> :)
63} ;
64
65declare function f:return-stub-obsstn($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()
66(: Returns a 'stubB' style observation station record to expand an observation station record :)
67(: Security not implemented here yet;  :)
68{
69let $SRObsStn := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[
70moles:dgMetadataID/moles:localIdentifier=$locid
71and
72moles:dgMetadataID/moles:repositoryIdentifier=$repid
73]
74return
75element {$out-element-name} {
76($SRObsStn/moles:dgMetadataID),
77($SRObsStn/moles:dgMetadataDescription),
78($SRObsStn/moles:name),
79($SRObsStn/moles:abbreviation),
80($SRObsStn/moles:logos)
81}
82} ;
83
84declare function f:return-stub-person($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()
85(: Returns a 'stubB' style observation station record to expand a person record :)
86(: Security not implemented yet :)
87{
88let $person := collection($targetCollection)/moles:dgMetadata/moles:dgPerson[
89moles:dgMetadataID/moles:localIdentifier=$locid
90and
91moles:dgMetadataID/moles:repositoryIdentifier=$repid
92]
93return
94element  {$out-element-name}
95{
96($person/moles:name),
97($person/moles:contactDetails),
98($person/moles:dgMetadataID)
99}
100} ;
101
102declare function f:return-stub-organisation($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()
103(: Returns a 'stubB' style observation station record to expand an organisation record :)
104(: Security not implemented yet :)
105{
106let $org := collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[
107moles:dgMetadataID/moles:localIdentifier=$locid
108and
109moles:dgMetadataID/moles:repositoryIdentifier=$repid
110]
111return
112element  {$out-element-name} {
113$org/moles:dgMetadataID,
114$org/moles:name,
115$org/moles:abbreviation,
116$org/moles:contactDetails,
117$org/moles:logos
118}
119} ;
120
121for $DPT in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[
122    moles:dgDataProductionTool!=''
123    and moles:dgMetadataID[
124    moles:schemeIdentifier='NDG-B0'
125    and moles:repositoryIdentifier=$repositoryIdentifier
126    and moles:localIdentifier=$localIdentifier]]
127    return
128utillib:strip-namespace(element dgMetadataRecord {
129    $DPT/dgMetadataID,
130        element dgMetadataID {
131            element schemeIdentifier {'NDG-B1'},
132            $DPT/moles:dgMetadataID/moles:repositoryIdentifier,
133            $DPT/moles:dgMetadataID/moles:localIdentifier
134        } (: End </dgMetadataID> :),
135    $DPT/moles:dgMetadataDescription,
136    $DPT/moles:name,
137    $DPT/moles:abbreviation,
138    element dgDataProductionTool {
139        $DPT/moles:contactDetails,
140        if (exists($DPT/moles:dgModel)) then $DPT/moles:dgModel
141        else $DPT/moles:dgInstrument
142    ,
143    if (exists($DPT/moles:dgDPTRoles)) then
144        element dgDPTRoles {'Roles are available, and will be added soon'}
145     else(),
146element DeploymentSummary {
147element activityList {
148for $DepActRepository in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ActivityID/moles:repositoryIdentifier)
149for $DepActLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ActivityID/moles:localIdentifier)
150let $DepAct :=  f:return-stub-activity('activity', data($DepActRepository), data($DepActLocal))
151return $DepAct
152},
153element obsStnList {
154for $DepObsStnRepository in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ObservationStationID/moles:repositoryIdentifier)
155for $DepObsStnLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ObservationStationID/moles:localIdentifier)
156let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal))
157return $DepObsStn
158},
159element dataEntityList {
160for $DE in
161collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment
162/moles:DataProductionToolID
163[moles:localIdentifier=$DPT/moles:dgMetadataID/moles:localIdentifier
164and moles:repositoryIdentifier=$DPT/moles:dgMetadataID/moles:repositoryIdentifier]]
165order by $DE/moles:dgMetadataID
166return f:return-stub-dataentity('dataentity', $DE)
167}
168, element rawDeployments {for $rawDeployments in $DPT/moles:dgDataProductionTool/moles:DPTDeployment return $rawDeployments}
169} (: </DeploymentSummary> :)
170} (: </dgDataProductionTool> :),
171    for $strkwrd in $DPT/moles:dgStructuredKeyword return $strkwrd,
172    if (exists($DPT/moles:dgMetadataProvenance)) then $DPT/moles:dgMetadataProvenance else (),
173    if (exists($DPT/moles:dgMetadataSecurity)) then $DPT/moles:dgMetadataSecurity else ()
174} (:End </dgMetadataRecord> :)
175) (: End namespace strip :)
Note: See TracBrowser for help on using the repository browser.