Changeset 2583


Ignore:
Timestamp:
13/06/07 09:30:14 (12 years ago)
Author:
ko23
Message:

New version of ndg_xqueries.py and examples of new StubBs?

Location:
TI07-MOLES/trunk
Files:
9 added
1 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/PythonCode/wsgi/ndg_xqueries.py

    r2554 r2583  
    1212ObjectTypeQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles';declare variable $targetCollection as xs:string {'TargetCollection'};for $Obj in collection($targetCollection)/dgMetadata/dgMetadataRecord[dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID']  return <objectType>{if (exists($Obj/dgDataEntity)) then 4 else (if (exists($Obj/dgObservationStation)) then 3 else (if (exists($Obj/dgDataProductionTool)) then 2 else (if (exists($Obj/dgActivity)) then 1 else (0))))}</objectType>''' 
    1313 
    14 StubBDEQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles/dataentity';  
     14StubBDEQuery = ''' 
     15declare default element namespace 'http://ndg.nerc.ac.uk/moles/dataentity';  
    1516declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
    1617declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    17 declare option exist:timeout '24500';  
     18 
    1819import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    1920import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
     
    2526declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    2627declare variable $localIdentifier as xs:string {'LocalID'}; 
     28(: replacable parameters 
     29declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     30declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     31declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
     32:) 
    2733 
    2834declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     
    3642element  {$out-element-name} {  
    3743($SRAct/moles:dgMetadataID), 
     44($SRAct/moles:dgMetadataDescription), 
    3845($SRAct/moles:name), 
    3946($SRAct/moles:abbreviation), 
    40 ($SRAct/moles:logos), 
    41 element dgActivity { 
    42 } (: </dgActivity> :)  
     47($SRAct/moles:logos) 
    4348} (: </activity> :)  
    4449} ; 
     
    5257element {$out-element-name} { 
    5358($SRDE/moles:dgMetadataID), 
     59($SRDE/moles:dgMetadataDescription), 
    5460($SRDE/moles:name), 
    55 ($SRDE/moles:abbreviation), 
    56 element dgDataEntity { 
     61($SRDE/moles:abbreviation) 
    5762} (: </dgDataEntity> :)         
    58 } 
    5963} ; 
    6064 
     
    7175element {$out-element-name} { 
    7276$SRDPT/moles:dgMetadataID, 
     77$SRDPT/moles:dgMetadataDescription, 
    7378$SRDPT/moles:name, 
    7479$SRDPT/moles:abbreviation, 
    75 $SRDPT/moles:logos, 
    76 element dgDataProductionTool { 
    77 } (: </dgDataProductionTool> :) 
     80$SRDPT/moles:logos 
    7881} (: </dataproductiontool> :) 
    7982} ; 
     
    9194element {$out-element-name} { 
    9295($SRObsStn/moles:dgMetadataID), 
     96($SRObsStn/moles:dgMetadataDescription), 
    9397($SRObsStn/moles:name), 
    9498($SRObsStn/moles:abbreviation), 
    95 ($SRObsStn/moles:logos), 
    96 element dgObservationStation { 
    97 } (: </dgObservationStation> :) 
     99($SRObsStn/moles:logos) 
    98100} 
    99101} ; 
     
    222224            else () 
    223225        } , (: </dgDataRoles> :) 
    224         for $RelDep in $DE/moles:dgDataEntity/moles:RelatedDeployment 
    225             return 
    226             element RelatedDeployment { 
    227             $RelDep/moles:DateStart, 
    228             $RelDep/moles:DateEnd, 
    229             $RelDep/moles:dgMetadataID, 
    230             f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    231             f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)), 
    232             f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), 
    233             $RelDep/moles:Coverage 
    234         } (: </RelatedDeployment> :)  
    235         , 
     226element DeploymentSummary { 
     227element activityList { 
     228for $DepActRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID/moles:repositoryIdentifier) 
     229for $DepActLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID/moles:localIdentifier) 
     230let $DepAct :=  f:return-stub-activity('activity', data($DepActRepository), data($DepActLocal)) 
     231return $DepAct  
     232}, 
     233element dptList { 
     234for $DepDPTRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:repositoryIdentifier) 
     235for $DepDPTLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     236let $DepDPT :=  f:return-stub-dpt('dataproductiontool', data($DepDPTRepository), data($DepDPTLocal)) 
     237return $DepDPT  
     238}, 
     239element obsStnList { 
     240for $DepObsStnRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     241for $DepObsStnLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     242let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
     243return $DepObsStn  
     244} 
     245} (: </DeploymentSummary> :) , 
    236246        for $RelatedDataEntity in $DE/moles:dgDataEntity/moles:dgRelatedDataEntity 
    237247            return 
     
    258268declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
    259269declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    260 declare option exist:timeout '24500';  
    261270 
    262271import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     
    265274Will return when scope problem sussed... ;( 
    266275import module namespace stubblib='http://ndg.nerc.ac.uk/xquery/lib/stubb' at 'xmldb:exist:///db/xqueryLib/StubB/stubb_xquery_lib.xquery'; 
     276:) 
     277(: replacable parameters 
     278declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     279declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     280declare variable $localIdentifier as xs:string {'activity_11680365144712080'}; 
    267281:) 
    268282declare variable $targetCollection as xs:string {'TargetCollection'}; 
     
    283297($SRAct/moles:name), 
    284298($SRAct/moles:abbreviation), 
    285 ($SRAct/moles:logos), 
    286 element dgActivity { 
    287 } (: </dgActivity> :)  
     299($SRAct/moles:logos) 
    288300} (: </activity> :)  
    289301} ; 
     
    299311($SRDE/moles:dgMetadataDescription), 
    300312($SRDE/moles:name), 
    301 ($SRDE/moles:abbreviation), 
    302 element dgDataEntity { 
     313($SRDE/moles:abbreviation) 
    303314} (: </dgDataEntity> :)         
    304 } 
    305315} ; 
    306316 
     
    320330$SRDPT/moles:name, 
    321331$SRDPT/moles:abbreviation, 
    322 $SRDPT/moles:logos, 
    323 element dgDataProductionTool { 
    324 } (: </dgDataProductionTool> :) 
     332$SRDPT/moles:logos 
    325333} (: </dataproductiontool> :) 
    326334} ; 
     
    341349($SRObsStn/moles:name), 
    342350($SRObsStn/moles:abbreviation), 
    343 ($SRObsStn/moles:logos), 
    344 element dgObservationStation { 
    345 } (: </dgObservationStation> :) 
     351($SRObsStn/moles:logos) 
    346352} 
    347353} ; 
     
    516522        else () 
    517523    }, (: </dgActivityRole> :) 
    518     for $RelDep in $Act/moles:dgActivity/moles:ActivityDeployment 
    519         return 
    520         element ActivityDeployment { 
    521             ($RelDep/moles:DateStart), 
    522             if (exists($RelDep/moles:DateEnd)) then  
    523                 ($RelDep/moles:DateEnd) 
    524             else (), 
    525             ($RelDep/moles:dgMetadataID), 
    526             f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)), 
    527             f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), 
    528                 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    529 and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
    530 return 
    531 f:return-stub-dataentity('dataentity', $DE) 
    532         }, (: </ActivityDeployment> :) 
     524element DeploymentSummary { 
     525element dptList { 
     526for $DepDPTRepository in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:DataProductionToolID/moles:repositoryIdentifier) 
     527for $DepDPTLocal in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     528let $DepDPT :=  f:return-stub-dpt('dataproductiontool', data($DepDPTRepository), data($DepDPTLocal)) 
     529return $DepDPT  
     530}, 
     531element obsStnList { 
     532for $DepObsStnRepository in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     533for $DepObsStnLocal in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     534let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
     535return $DepObsStn  
     536}, 
     537element dataEntityList { 
     538for $DE in  
     539collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment 
     540/moles:DataProductionToolID 
     541[moles:localIdentifier=$Act/moles:dgMetadataID/moles:localIdentifier 
     542and moles:repositoryIdentifier=$Act/moles:dgMetadataID/moles:repositoryIdentifier]] 
     543order by $DE/moles:dgMetadataID 
     544return f:return-stub-dataentity('dataentity', $DE) 
     545} 
     546}, (: </DeploymentSummary> :) 
    533547        if (exists($Act/dgActivityCoverage)) then 
    534548            ($Act/dgActivityCoverage) 
     
    549563import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    550564import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
    551 declare option exist:timeout '24500';  
    552565(:  
    553566Will return when scope problem sussed... ;( 
     
    557570declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    558571 
     572(: replacable parameters 
     573declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     574declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     575declare variable $localIdentifier as xs:string {'dpt_116291244849226'}; 
     576:) 
    559577declare variable $targetCollection as xs:string {'TargetCollection'}; 
    560578declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
     
    571589element  {$out-element-name} {  
    572590($SRAct/moles:dgMetadataID), 
     591($SRAct/moles:dgMetadataDescription), 
    573592($SRAct/moles:name), 
    574593($SRAct/moles:abbreviation), 
    575 ($SRAct/moles:logos), 
    576 element dgActivity { 
    577 } (: </dgActivity> :)  
     594($SRAct/moles:logos) 
    578595} (: </activity> :)  
    579596} ; 
     
    587604element {$out-element-name} { 
    588605($SRDE/moles:dgMetadataID), 
     606($SRDE/moles:dgMetadataDescription), 
    589607($SRDE/moles:name), 
    590 ($SRDE/moles:abbreviation), 
    591 element dgDataEntity { 
     608($SRDE/moles:abbreviation) 
    592609} (: </dgDataEntity> :)         
    593 } 
    594610} ; 
    595611 
     
    606622element {$out-element-name} { 
    607623$SRDPT/moles:dgMetadataID, 
     624$SRDPT/moles:dgMetadataDescription, 
    608625$SRDPT/moles:name, 
    609626$SRDPT/moles:abbreviation, 
    610 $SRDPT/moles:logos, 
    611 element dgDataProductionTool { 
    612 } (: </dgDataProductionTool> :) 
     627$SRDPT/moles:logos 
    613628} (: </dataproductiontool> :) 
    614629} ; 
     
    626641element {$out-element-name} { 
    627642($SRObsStn/moles:dgMetadataID), 
     643($SRObsStn/moles:dgMetadataDescription), 
    628644($SRObsStn/moles:name), 
    629645($SRObsStn/moles:abbreviation), 
    630 ($SRObsStn/moles:logos), 
    631 element dgObservationStation { 
    632 } (: </dgObservationStation> :) 
     646($SRObsStn/moles:logos) 
    633647} 
    634648} ; 
     
    696710        element dgDPTRoles {'Roles are available, and will be added soon'}  
    697711     else(), 
    698     for $RelDep in $DPT/moles:dgDataProductionTool/moles:DPTDeployment  
    699     return  
    700         element DPTDeployment {  
    701             $RelDep/moles:DateStart, 
    702             $RelDep/moles:DateEnd, 
    703             $RelDep/moles:dgMetadataID, 
    704             f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    705             f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), 
    706                 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    707 and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
    708 return 
    709 f:return-stub-dataentity('dataentity', $DE), 
    710             $RelDep/moles:Coverage 
    711         } (: </DPTDeployment> :)  
    712     } (: </dgDataProductionTool> :),  
     712element DeploymentSummary { 
     713element activityList { 
     714for $DepActRepository in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ActivityID/moles:repositoryIdentifier) 
     715for $DepActLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ActivityID/moles:localIdentifier) 
     716let $DepAct :=  f:return-stub-activity('activity', data($DepActRepository), data($DepActLocal)) 
     717return $DepAct  
     718}, 
     719element obsStnList { 
     720for $DepObsStnRepository in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     721for $DepObsStnLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     722let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
     723return $DepObsStn  
     724}, 
     725element dataEntityList { 
     726for $DE in  
     727collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment 
     728/moles:DataProductionToolID 
     729[moles:localIdentifier=$DPT/moles:dgMetadataID/moles:localIdentifier 
     730and moles:repositoryIdentifier=$DPT/moles:dgMetadataID/moles:repositoryIdentifier]] 
     731order by $DE/moles:dgMetadataID 
     732return f:return-stub-dataentity('dataentity', $DE) 
     733} 
     734} (: </DeploymentSummary> :) 
     735} (: </dgDataProductionTool> :),  
    713736    for $strkwrd in $DPT/moles:dgStructuredKeyword return $strkwrd, 
    714737    if (exists($DPT/moles:dgMetadataProvenance)) then $DPT/moles:dgMetadataProvenance else (), 
     
    722745import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    723746import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
    724 declare option exist:timeout '24500';  
    725747(:  
    726748Will return when scope problem sussed... ;( 
     
    730752declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    731753 
     754(: replacable parameters 
     755declare variable $targetCollection as xs:string {'/db/ndg_B_metadata_4'}; 
     756declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     757declare variable $localIdentifier as xs:string {'obs_1162914661529326'}; 
     758:) 
    732759declare variable $targetCollection as xs:string {'TargetCollection'}; 
    733760declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    734761declare variable $localIdentifier as xs:string {'LocalID'}; 
    735  
    736762declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
    737763(: Returns a 'stubB' style activity record to expand an activity record :) 
     
    744770element  {$out-element-name} {  
    745771($SRAct/moles:dgMetadataID), 
     772($SRAct/moles:dgMetadataDescription), 
    746773($SRAct/moles:name), 
    747774($SRAct/moles:abbreviation), 
    748 ($SRAct/moles:logos), 
    749 element dgActivity { 
    750 } (: </dgActivity> :)  
     775($SRAct/moles:logos) 
    751776} (: </activity> :)  
    752777} ; 
     
    760785element {$out-element-name} { 
    761786($SRDE/moles:dgMetadataID), 
     787($SRDE/moles:dgMetadataDescription), 
    762788($SRDE/moles:name), 
    763 ($SRDE/moles:abbreviation), 
    764 element dgDataEntity { 
     789($SRDE/moles:abbreviation) 
    765790} (: </dgDataEntity> :)         
    766 } 
    767791} ; 
    768792 
     
    779803element {$out-element-name} { 
    780804$SRDPT/moles:dgMetadataID, 
     805$SRDPT/moles:dgMetadataDescription, 
    781806$SRDPT/moles:name, 
    782807$SRDPT/moles:abbreviation, 
    783 $SRDPT/moles:logos, 
    784 element dgDataProductionTool { 
    785 } (: </dgDataProductionTool> :) 
     808$SRDPT/moles:logos 
    786809} (: </dataproductiontool> :) 
    787810} ; 
     
    799822element {$out-element-name} { 
    800823($SRObsStn/moles:dgMetadataID), 
     824($SRObsStn/moles:dgMetadataDescription), 
    801825($SRObsStn/moles:name), 
    802826($SRObsStn/moles:abbreviation), 
    803 ($SRObsStn/moles:logos), 
    804 element dgObservationStation { 
    805 } (: </dgObservationStation> :) 
     827($SRObsStn/moles:logos) 
    806828} 
    807829} ; 
     
    847869moles:dgObservationStation!=''  
    848870and moles:dgMetadataID[ 
    849 moles:schemeIdentifier='NDG-B0'  
    850 and moles:repositoryIdentifier=$repositoryIdentifier 
     871moles:repositoryIdentifier=$repositoryIdentifier 
    851872and moles:localIdentifier=$localIdentifier]] 
    852873return 
     
    891912} (: End </dgStationaryPlatform>  :)   
    892913else $ObsStn/moles:dgObservationStation/moles:dgMovingPlatform ,  
    893 for $RelDep in $ObsStn/moles:dgObservationStation/moles:ObsStationDeployment  
    894 return  
    895 element ObsStationDeployment { 
    896 $RelDep/moles:DateStart, 
    897 $RelDep/moles:DateEnd, 
    898 $RelDep/moles:dgMetadataID, 
    899 f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    900 f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)),  
    901 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    902 and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
    903 return 
    904 f:return-stub-dataentity('dataentity', $DE), 
    905 $RelDep/moles:Coverage 
    906 } (: </RelatedDeployment> :)  
     914element DeploymentSummary { 
     915element activityList { 
     916for $DepActRepository in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:ActivityID/moles:repositoryIdentifier) 
     917for $DepActLocal in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:ActivityID/moles:localIdentifier) 
     918let $DepAct :=  f:return-stub-activity('activity', data($DepActRepository), data($DepActLocal)) 
     919return $DepAct  
     920}, 
     921element dptList { 
     922for $DepDPTRepository in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:DataProductionToolID/moles:repositoryIdentifier) 
     923for $DepDPTLocal in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     924let $DepDPT :=  f:return-stub-dpt('dataproductiontool', data($DepDPTRepository), data($DepDPTLocal)) 
     925return $DepDPT  
     926}, 
     927element dataEntityList { 
     928for $DE in  
     929collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment 
     930/moles:ObservationStationID 
     931[moles:localIdentifier=$ObsStn/moles:dgMetadataID/moles:localIdentifier 
     932and moles:repositoryIdentifier=$ObsStn/moles:dgMetadataID/moles:repositoryIdentifier]] 
     933order by $DE/moles:dgMetadataID 
     934return f:return-stub-dataentity('dataentity', $DE) 
     935} 
     936} (: </DeploymentSummary> :)  
    907937} (: </dgObservationStation> :),  
    908938for $strkwrd in $ObsStn/moles:dgStructuredKeyword return $strkwrd, 
     
    11311161import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    11321162import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
     1163(: Keep 
    11331164declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; 
    11341165declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    11351166declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    1136 declare option exist:timeout '24500';  
     1167:) 
    11371168declare variable $targetCollection as xs:string {'TargetCollection'}; 
    11381169declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    11391170declare variable $localIdentifier as xs:string {'LocalID'}; 
     1171declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     1172declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     1173declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
    11401174 
    11411175let $DE := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     
    11511185            for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] 
    11521186        return  
    1153             for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[( 
    1154                    moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
    1155                    and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
     1187            for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(dgOrganisation | dgPerson)[( 
     1188                   moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:repositoryIdentifier 
     1189                   and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:localIdentifier)] 
    11561190            return  
    11571191                    element Dataset_Creator { 
     
    14351469''' 
    14361470         
    1437 DublinCoreDEQuery='''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     1471DublinCoreDEQuery=''' 
     1472import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    14381473import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
    14391474declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
    14401475declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    14411476declare namespace dc='http://purl.org/dc/elements/1.1/'; 
    1442 declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc'; 
     1477declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc/'; 
     1478(: 
     1479declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     1480declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     1481declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
     1482:) 
     1483 
    14431484declare variable $targetCollection as xs:string {'TargetCollection'}; 
    14441485declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
     
    14471488for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[ 
    14481489exists('dgDataEntity')  
    1449 and dgMetadataID/schemeIdentifier='NDG-B0'  
    14501490and dgMetadataID/repositoryIdentifier=$repositoryIdentifier 
    14511491and dgMetadataID/localIdentifier=$localIdentifier] 
     
    14561496    element dc:type {'Dataset'}, 
    14571497    element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, $utillib:moles_id_separator, 'DC', $utillib:moles_id_separator, $DE/dgMetadataID/localIdentifier)}, 
     1498    for $identifiers in $DE/(dgMetadataDescription/descriptionSection/descriptionOnlineReference | abstract/abstractOnlineReference)[ 
     1499        exists(dgReferenceClass/dgValidTermID/ParentListID) 
     1500        and 
     1501        voclib:spot-vocab($voclib:ndg_online_reference_classes_vocab, dgReferenceClass/dgValidTermID/ParentListID)  
     1502        and 
     1503        dgReferenceClass/dgValidTerm='DataPage'] 
     1504    return element dc:identifier {data($identifiers/dgSimpleLink/URI)}, 
    14581505    element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)}, 
    14591506    element dc:date 
     
    14611508        if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then 
    14621509            for $updatedate in ($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate) 
    1463                 order by xs:dateTime($updatedate) 
     1510                order by xs:date($updatedate) 
    14641511            return data($updatedate[1]) 
    14651512        else 
     
    15161563                    (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName)))) 
    15171564                else ('empty content') 
    1518             } 
    1519 }  (: </oai_dc:dc> :)''' 
     1565} 
     1566}  (: </oai_dc:dc> :) 
     1567''' 
    15201568 
    15211569MDIPQuery='''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     
    16101658    } 
    16111659''' 
    1612  
    1613  
Note: See TracChangeset for help on using the changeset viewer.