Ignore:
Timestamp:
09/05/07 16:23:59 (13 years ago)
Author:
ko23
Message:

Updated DIF queries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/StubB/XQuery/NDG-DEStubB.xquery

    r2367 r2464  
    99import module namespace stubblib='http://ndg.nerc.ac.uk/xquery/lib/stubb' at 'xmldb:exist:///db/xqueryLib/StubB/stubb_xquery_lib.xquery'; 
    1010:) 
     11declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     12declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     13declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
     14(: replacable parameters 
    1115declare variable $targetCollection as xs:string {'TargetCollection'}; 
    1216declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    1317declare variable $localIdentifier as xs:string {'LocalID'}; 
     18:) 
    1419 
    1520declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     
    1722(: Security not implemented here yet :) 
    1823{ 
    19 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    20             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    21             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    22 return   
    23     if ($found = 0) then  
    24         element {$out-element-name} { 
    25             element error {'not found'}, 
    26             element repositoryIdentifier {$repid}, 
    27             element localIdentifier {$locid} 
    28         }  
    29     else ( 
    3024        for $SRAct in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    3125            moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     
    5044                } (: </dgActivity> :)  
    5145            } (: </activity> :)  
    52     ) 
    5346} ; 
    5447 
     
    5750(: Security not implemented yet :) 
    5851{ 
    59 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    60         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    61         and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    62 return   
    63     if ($found = 0) then  
    64         element {$out-element-name} { 
    65             element error {'not found'}, 
    66             element repositoryIdentifier {$repid}, 
    67             element localIdentifier {$locid} 
    68         }  
    69     else ( 
    7052        for $SRDE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    7153            moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     
    8365                } (: </dgDataEntity> :)         
    8466            } 
    85     ) 
    8667} ; 
    8768 
     
    9071(: Security not implemented yet :) 
    9172{ 
    92 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    93         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    94         and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    95 return   
    96     if ($found = 0) then  
    97         element {$out-element-name} { 
    98             element error {'not found'}, 
    99             element repositoryIdentifier {$repid}, 
    100             element localIdentifier {$locid} 
    101         }  
    102     else ( 
    10373        for $SRDPT in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    10474                moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     
    12191                    } (: </dgDataProductionTool> :) 
    12292                } (: </dataproductiontool> :) 
    123     ) 
    12493} ; 
    12594 
     
    12897(: Security not implemented here yet;  :) 
    12998{ 
    130 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    131             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    132             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    133 return   
    134     if ($found = 0) then  
    135         element {$out-element-name} { 
    136             element error {'not found'}, 
    137             element repositoryIdentifier {$repid}, 
    138             element localIdentifier {$locid} 
    139         }  
    140     else ( 
    14199        for $SRObsStn in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    142100            moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     
    163121                } (: </dgObservationStation> :) 
    164122            } 
    165     ) 
    166123} ; 
    167124 
     
    170127(: Security not implemented yet :) 
    171128{ 
    172 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    173             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    174             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    175 return   
    176     if ($found = 0) then  
    177         element {$out-element-name} { 
    178             element error {'not found'}, 
    179             element repositoryIdentifier {$repid}, 
    180             element localIdentifier {$locid} 
    181         }  
    182     else ( 
    183129    for $person in collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    184130        moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     
    191137            ($person/moles:dgMetadataID) 
    192138        } 
    193     ) 
    194139} ; 
    195140 
     
    198143(: Security not implemented yet :) 
    199144{ 
    200     let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    201                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    202                 and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    203     return   
    204         if ($found = 0) then  
    205             element {$out-element-name} { 
    206                 element error {'not found'}, 
    207                 element repositoryIdentifier {$repid}, 
    208                 element localIdentifier {$locid} 
    209             }  
    210         else ( 
    211145            for $org in collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    212146                moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     
    220154                    $org/moles:logos 
    221155                } 
    222         ) 
    223156} ; 
    224157 
Note: See TracChangeset for help on using the changeset viewer.