Ignore:
Timestamp:
22/06/07 17:49:17 (13 years ago)
Author:
lawrence
Message:

Shopping cart, history and login framework for ows/discovery/browse.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/ndg_xqueries.py

    r2615 r2639  
    22# TI07-MOLES/trunk/JavaCode/returnmolesxmldb/ndg/services/returnmoles/Main.java 
    33# Update DIF/DC queries  
     4 
     5csmlQuery='''declare default element namespace 'http://ndg.nerc.ac.uk/csml';  
     6for $DE in collection('TargetCollection')/Dataset[@id='LocalID'] return $DE''' 
     7 
    48listingQuery=''' 
    59declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $DE 
     
    1216ObjectTypeQuery = '''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>''' 
    1317 
    14 StubBDEQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles/dataentity';  
     18StubBDEQuery = ''' 
     19declare default element namespace 'http://ndg.nerc.ac.uk/moles/dataentity';  
    1520declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
    1621declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
     
    2530declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    2631declare variable $localIdentifier as xs:string {'LocalID'}; 
     32(: replacable parameters 
     33declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     34declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     35declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
     36:) 
    2737 
    2838declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     
    3646element  {$out-element-name} {  
    3747($SRAct/moles:dgMetadataID), 
     48($SRAct/moles:dgMetadataDescription), 
    3849($SRAct/moles:name), 
    3950($SRAct/moles:abbreviation), 
    40 ($SRAct/moles:logos), 
    41 element dgActivity { 
    42 } (: </dgActivity> :)  
     51($SRAct/moles:logos) 
    4352} (: </activity> :)  
    4453} ; 
     
    5261element {$out-element-name} { 
    5362($SRDE/moles:dgMetadataID), 
     63($SRDE/moles:dgMetadataDescription), 
    5464($SRDE/moles:name), 
    55 ($SRDE/moles:abbreviation), 
    56 element dgDataEntity { 
     65($SRDE/moles:abbreviation) 
    5766} (: </dgDataEntity> :)         
    58 } 
    5967} ; 
    6068 
     
    7179element {$out-element-name} { 
    7280$SRDPT/moles:dgMetadataID, 
     81$SRDPT/moles:dgMetadataDescription, 
    7382$SRDPT/moles:name, 
    7483$SRDPT/moles:abbreviation, 
    75 $SRDPT/moles:logos, 
    76 element dgDataProductionTool { 
    77 } (: </dgDataProductionTool> :) 
     84$SRDPT/moles:logos 
    7885} (: </dataproductiontool> :) 
    7986} ; 
     
    9198element {$out-element-name} { 
    9299($SRObsStn/moles:dgMetadataID), 
     100($SRObsStn/moles:dgMetadataDescription), 
    93101($SRObsStn/moles:name), 
    94102($SRObsStn/moles:abbreviation), 
    95 ($SRObsStn/moles:logos), 
    96 element dgObservationStation { 
    97 } (: </dgObservationStation> :) 
     103($SRObsStn/moles:logos) 
    98104} 
    99105} ; 
     
    222228            else () 
    223229        } , (: </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         , 
     230element DeploymentSummary { 
     231element activityList { 
     232for $DepActRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID/moles:repositoryIdentifier) 
     233for $DepActLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID/moles:localIdentifier) 
     234let $DepAct :=  f:return-stub-activity('activity', data($DepActRepository), data($DepActLocal)) 
     235return $DepAct  
     236}, 
     237element dptList { 
     238for $DepDPTRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:repositoryIdentifier) 
     239for $DepDPTLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     240let $DepDPT :=  f:return-stub-dpt('dataproductiontool', data($DepDPTRepository), data($DepDPTLocal)) 
     241return $DepDPT  
     242}, 
     243element obsStnList { 
     244for $DepObsStnRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     245for $DepObsStnLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     246let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
     247return $DepObsStn  
     248} 
     249} (: </DeploymentSummary> :) , 
    236250        for $RelatedDataEntity in $DE/moles:dgDataEntity/moles:dgRelatedDataEntity 
    237251            return 
     
    265279import module namespace stubblib='http://ndg.nerc.ac.uk/xquery/lib/stubb' at 'xmldb:exist:///db/xqueryLib/StubB/stubb_xquery_lib.xquery'; 
    266280:) 
     281(: replacable parameters 
     282declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     283declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     284declare variable $localIdentifier as xs:string {'activity_11680365144712080'}; 
     285:) 
    267286declare variable $targetCollection as xs:string {'TargetCollection'}; 
    268287declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
     
    282301($SRAct/moles:name), 
    283302($SRAct/moles:abbreviation), 
    284 ($SRAct/moles:logos), 
    285 element dgActivity { 
    286 } (: </dgActivity> :)  
     303($SRAct/moles:logos) 
    287304} (: </activity> :)  
    288305} ; 
     
    298315($SRDE/moles:dgMetadataDescription), 
    299316($SRDE/moles:name), 
    300 ($SRDE/moles:abbreviation), 
    301 element dgDataEntity { 
     317($SRDE/moles:abbreviation) 
    302318} (: </dgDataEntity> :)         
    303 } 
    304319} ; 
    305320 
     
    319334$SRDPT/moles:name, 
    320335$SRDPT/moles:abbreviation, 
    321 $SRDPT/moles:logos, 
    322 element dgDataProductionTool { 
    323 } (: </dgDataProductionTool> :) 
     336$SRDPT/moles:logos 
    324337} (: </dataproductiontool> :) 
    325338} ; 
     
    340353($SRObsStn/moles:name), 
    341354($SRObsStn/moles:abbreviation), 
    342 ($SRObsStn/moles:logos), 
    343 element dgObservationStation { 
    344 } (: </dgObservationStation> :) 
     355($SRObsStn/moles:logos) 
    345356} 
    346357} ; 
     
    515526        else () 
    516527    }, (: </dgActivityRole> :) 
    517     for $RelDep in $Act/moles:dgActivity/moles:ActivityDeployment 
    518         return 
    519         element ActivityDeployment { 
    520             ($RelDep/moles:DateStart), 
    521             if (exists($RelDep/moles:DateEnd)) then  
    522                 ($RelDep/moles:DateEnd) 
    523             else (), 
    524             ($RelDep/moles:dgMetadataID), 
    525             f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)), 
    526             f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), 
    527                 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    528 and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
    529 return 
    530 f:return-stub-dataentity('dataentity', $DE) 
    531         }, (: </ActivityDeployment> :) 
     528element DeploymentSummary { 
     529element dptList { 
     530for $DepDPTRepository in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:DataProductionToolID/moles:repositoryIdentifier) 
     531for $DepDPTLocal in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     532let $DepDPT :=  f:return-stub-dpt('dataproductiontool', data($DepDPTRepository), data($DepDPTLocal)) 
     533return $DepDPT  
     534}, 
     535element obsStnList { 
     536for $DepObsStnRepository in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     537for $DepObsStnLocal in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     538let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
     539return $DepObsStn  
     540}, 
     541element dataEntityList { 
     542for $DE in  
     543collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment 
     544/moles:DataProductionToolID 
     545[moles:localIdentifier=$Act/moles:dgMetadataID/moles:localIdentifier 
     546and moles:repositoryIdentifier=$Act/moles:dgMetadataID/moles:repositoryIdentifier]] 
     547order by $DE/moles:dgMetadataID 
     548return f:return-stub-dataentity('dataentity', $DE) 
     549} 
     550}, (: </DeploymentSummary> :) 
    532551        if (exists($Act/dgActivityCoverage)) then 
    533552            ($Act/dgActivityCoverage) 
     
    555574declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    556575 
     576(: replacable parameters 
     577declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     578declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     579declare variable $localIdentifier as xs:string {'dpt_116291244849226'}; 
     580:) 
    557581declare variable $targetCollection as xs:string {'TargetCollection'}; 
    558582declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
     
    569593element  {$out-element-name} {  
    570594($SRAct/moles:dgMetadataID), 
     595($SRAct/moles:dgMetadataDescription), 
    571596($SRAct/moles:name), 
    572597($SRAct/moles:abbreviation), 
    573 ($SRAct/moles:logos), 
    574 element dgActivity { 
    575 } (: </dgActivity> :)  
     598($SRAct/moles:logos) 
    576599} (: </activity> :)  
    577600} ; 
     
    585608element {$out-element-name} { 
    586609($SRDE/moles:dgMetadataID), 
     610($SRDE/moles:dgMetadataDescription), 
    587611($SRDE/moles:name), 
    588 ($SRDE/moles:abbreviation), 
    589 element dgDataEntity { 
     612($SRDE/moles:abbreviation) 
    590613} (: </dgDataEntity> :)         
    591 } 
    592614} ; 
    593615 
     
    604626element {$out-element-name} { 
    605627$SRDPT/moles:dgMetadataID, 
     628$SRDPT/moles:dgMetadataDescription, 
    606629$SRDPT/moles:name, 
    607630$SRDPT/moles:abbreviation, 
    608 $SRDPT/moles:logos, 
    609 element dgDataProductionTool { 
    610 } (: </dgDataProductionTool> :) 
     631$SRDPT/moles:logos 
    611632} (: </dataproductiontool> :) 
    612633} ; 
     
    624645element {$out-element-name} { 
    625646($SRObsStn/moles:dgMetadataID), 
     647($SRObsStn/moles:dgMetadataDescription), 
    626648($SRObsStn/moles:name), 
    627649($SRObsStn/moles:abbreviation), 
    628 ($SRObsStn/moles:logos), 
    629 element dgObservationStation { 
    630 } (: </dgObservationStation> :) 
     650($SRObsStn/moles:logos) 
    631651} 
    632652} ; 
     
    694714        element dgDPTRoles {'Roles are available, and will be added soon'}  
    695715     else(), 
    696     for $RelDep in $DPT/moles:dgDataProductionTool/moles:DPTDeployment  
    697     return  
    698         element DPTDeployment {  
    699             $RelDep/moles:DateStart, 
    700             $RelDep/moles:DateEnd, 
    701             $RelDep/moles:dgMetadataID, 
    702             f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    703             f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), 
    704                 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    705 and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
    706 return 
    707 f:return-stub-dataentity('dataentity', $DE), 
    708             $RelDep/moles:Coverage 
    709         } (: </DPTDeployment> :)  
    710     } (: </dgDataProductionTool> :),  
     716element DeploymentSummary { 
     717element activityList { 
     718for $DepActRepository in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ActivityID/moles:repositoryIdentifier) 
     719for $DepActLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ActivityID/moles:localIdentifier) 
     720let $DepAct :=  f:return-stub-activity('activity', data($DepActRepository), data($DepActLocal)) 
     721return $DepAct  
     722}, 
     723element obsStnList { 
     724for $DepObsStnRepository in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     725for $DepObsStnLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     726let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
     727return $DepObsStn  
     728}, 
     729element dataEntityList { 
     730for $DE in  
     731collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment 
     732/moles:DataProductionToolID 
     733[moles:localIdentifier=$DPT/moles:dgMetadataID/moles:localIdentifier 
     734and moles:repositoryIdentifier=$DPT/moles:dgMetadataID/moles:repositoryIdentifier]] 
     735order by $DE/moles:dgMetadataID 
     736return f:return-stub-dataentity('dataentity', $DE) 
     737} 
     738} (: </DeploymentSummary> :) 
     739} (: </dgDataProductionTool> :),  
    711740    for $strkwrd in $DPT/moles:dgStructuredKeyword return $strkwrd, 
    712741    if (exists($DPT/moles:dgMetadataProvenance)) then $DPT/moles:dgMetadataProvenance else (), 
     
    727756declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    728757 
     758(: replacable parameters 
     759declare variable $targetCollection as xs:string {'/db/ndg_B_metadata_4'}; 
     760declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     761declare variable $localIdentifier as xs:string {'obs_1162914661529326'}; 
     762:) 
    729763declare variable $targetCollection as xs:string {'TargetCollection'}; 
    730764declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    731765declare variable $localIdentifier as xs:string {'LocalID'}; 
    732  
    733766declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
    734767(: Returns a 'stubB' style activity record to expand an activity record :) 
     
    741774element  {$out-element-name} {  
    742775($SRAct/moles:dgMetadataID), 
     776($SRAct/moles:dgMetadataDescription), 
    743777($SRAct/moles:name), 
    744778($SRAct/moles:abbreviation), 
    745 ($SRAct/moles:logos), 
    746 element dgActivity { 
    747 } (: </dgActivity> :)  
     779($SRAct/moles:logos) 
    748780} (: </activity> :)  
    749781} ; 
     
    757789element {$out-element-name} { 
    758790($SRDE/moles:dgMetadataID), 
     791($SRDE/moles:dgMetadataDescription), 
    759792($SRDE/moles:name), 
    760 ($SRDE/moles:abbreviation), 
    761 element dgDataEntity { 
     793($SRDE/moles:abbreviation) 
    762794} (: </dgDataEntity> :)         
    763 } 
    764795} ; 
    765796 
     
    776807element {$out-element-name} { 
    777808$SRDPT/moles:dgMetadataID, 
     809$SRDPT/moles:dgMetadataDescription, 
    778810$SRDPT/moles:name, 
    779811$SRDPT/moles:abbreviation, 
    780 $SRDPT/moles:logos, 
    781 element dgDataProductionTool { 
    782 } (: </dgDataProductionTool> :) 
     812$SRDPT/moles:logos 
    783813} (: </dataproductiontool> :) 
    784814} ; 
     
    796826element {$out-element-name} { 
    797827($SRObsStn/moles:dgMetadataID), 
     828($SRObsStn/moles:dgMetadataDescription), 
    798829($SRObsStn/moles:name), 
    799830($SRObsStn/moles:abbreviation), 
    800 ($SRObsStn/moles:logos), 
    801 element dgObservationStation { 
    802 } (: </dgObservationStation> :) 
     831($SRObsStn/moles:logos) 
    803832} 
    804833} ; 
     
    844873moles:dgObservationStation!=''  
    845874and moles:dgMetadataID[ 
    846 moles:schemeIdentifier='NDG-B0'  
    847 and moles:repositoryIdentifier=$repositoryIdentifier 
     875moles:repositoryIdentifier=$repositoryIdentifier 
    848876and moles:localIdentifier=$localIdentifier]] 
    849877return 
     
    888916} (: End </dgStationaryPlatform>  :)   
    889917else $ObsStn/moles:dgObservationStation/moles:dgMovingPlatform ,  
    890 for $RelDep in $ObsStn/moles:dgObservationStation/moles:ObsStationDeployment  
    891 return  
    892 element ObsStationDeployment { 
    893 $RelDep/moles:DateStart, 
    894 $RelDep/moles:DateEnd, 
    895 $RelDep/moles:dgMetadataID, 
    896 f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    897 f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)),  
    898 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    899 and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
    900 return 
    901 f:return-stub-dataentity('dataentity', $DE), 
    902 $RelDep/moles:Coverage 
    903 } (: </RelatedDeployment> :)  
     918element DeploymentSummary { 
     919element activityList { 
     920for $DepActRepository in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:ActivityID/moles:repositoryIdentifier) 
     921for $DepActLocal in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:ActivityID/moles:localIdentifier) 
     922let $DepAct :=  f:return-stub-activity('activity', data($DepActRepository), data($DepActLocal)) 
     923return $DepAct  
     924}, 
     925element dptList { 
     926for $DepDPTRepository in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:DataProductionToolID/moles:repositoryIdentifier) 
     927for $DepDPTLocal in distinct-values($ObsStn/moles:dgObservationStation/moles:ObsStationDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     928let $DepDPT :=  f:return-stub-dpt('dataproductiontool', data($DepDPTRepository), data($DepDPTLocal)) 
     929return $DepDPT  
     930}, 
     931element dataEntityList { 
     932for $DE in  
     933collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment 
     934/moles:ObservationStationID 
     935[moles:localIdentifier=$ObsStn/moles:dgMetadataID/moles:localIdentifier 
     936and moles:repositoryIdentifier=$ObsStn/moles:dgMetadataID/moles:repositoryIdentifier]] 
     937order by $DE/moles:dgMetadataID 
     938return f:return-stub-dataentity('dataentity', $DE) 
     939} 
     940} (: </DeploymentSummary> :)  
    904941} (: </dgObservationStation> :),  
    905942for $strkwrd in $ObsStn/moles:dgStructuredKeyword return $strkwrd, 
     
    921958declare namespace xlink='http://www.w3.org/1999/xlink';  
    922959declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
     960declare option exist:timeout '24500';  
    923961 
    924962declare variable $targetCollection as xs:string {'TargetCollection'}; 
     
    11241162    return $Moles ''' 
    11251163             
    1126 DIFQuery = '''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     1164DIFQuery = ''' 
     1165import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    11271166import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
     1167(: Keep 
    11281168declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; 
    11291169declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    11301170declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    1131  
     1171:) 
    11321172declare variable $targetCollection as xs:string {'TargetCollection'}; 
    11331173declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    11341174declare variable $localIdentifier as xs:string {'LocalID'}; 
    1135  
    1136 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     1175declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     1176declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     1177declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
     1178 
     1179let $DE := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    11371180    exists('moles:dgDataEntity')  
    1138     and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'  
    11391181    and moles:dgMetadataID/moles:repositoryIdentifier=$repositoryIdentifier 
    11401182    and moles:dgMetadataID/moles:localIdentifier=$localIdentifier] 
     
    11471189            for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] 
    11481190        return  
    1149             for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
    1150                    and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
    1151                    and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
     1191            for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(dgOrganisation | dgPerson)[( 
     1192                   moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:repositoryIdentifier 
     1193                   and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:localIdentifier)] 
    11521194            return  
    11531195                    element Dataset_Creator { 
     
    11641206            element Parameters { 
    11651207            element Category {string($StructuredKeyword/*/moles:dgValidTerm)}, 
    1166             if (exists($StructuredKeyword//moles:dgValidSubterm)  
    1167                 and $StructuredKeyword//moles:dgValidSubterm != ''  
    1168                 and $StructuredKeyword//moles:dgValidSubterm != ' ') then  
     1208            if (exists($StructuredKeyword/*/moles:dgValidSubterm)  
     1209                and $StructuredKeyword/*/moles:dgValidSubterm != ''  
     1210                and $StructuredKeyword/*/moles:dgValidSubterm != ' ') then  
    11691211            for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)] 
    11701212                where exists($Subterm/moles:dgValidSubterm) 
     
    11751217                    else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    11761218                    else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    1177                     else element GCMD_Science_Valid {$Subterm/moles:ListLevel,($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
     1219                    else element GCMD_Science_Valid {data($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
    11781220            else() 
    11791221                } 
    11801222        else(), 
    1181     for $StructuredKeyword in ($DE//(moles:dgStructuredKeyword | moles:dgDataEntity/moles:dgDataSummary/moles:dgParameterSummary/moles:dgStdParameterMeasured)[voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_deprecated, moles:dgValidTermID/moles:ParentListID) and (not(exists(moles:ListLevel)) or moles:ListLevel=0)]) 
     1223    for $StructuredKeyword in ($DE/(moles:dgStructuredKeyword | moles:dgDataEntity/moles:dgDataSummary/moles:dgParameterSummary/moles:dgStdParameterMeasured)[voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_deprecated, moles:dgValidTermID/moles:ParentListID) and (not(exists(moles:ListLevel)) or moles:ListLevel=0)]) 
    11821224    return 
    11831225        element Parameters {data($StructuredKeyword/moles:dgValidTerm)}, 
     
    11851227        return  
    11861228            element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)}, 
    1187     for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ 
     1229    for $Keyword in distinct-values($DE/moles:dgStructuredKeyword[ 
    11881230    not (voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID) 
    11891231    or voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) 
    11901232    or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) 
     1233    or voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID) 
    11911234    )]/moles:dgValidTerm) 
    11921235    return element Keyword {string($Keyword)},  
    1193     for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID 
    1194     return  
    1195         element Sensor_Name { 
    1196             for $DepDPTAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:abbreviation)) 
    1197                 return element Short_Name {data($DepDPTAbbrev)}, 
    1198             for $DepDPTName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:name)) 
    1199                 return element Long_Name {data($DepDPTName)} 
     1236    for $DepDPTRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:repositoryIdentifier 
     1237    for $DepDPTLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID[moles:repositoryIdentifier=$DepDPTRepository]/moles:localIdentifier)  
     1238    let $DepDPTRecord := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPTRepository  and moles:localIdentifier=$DepDPTLocal]] 
     1239                return 
     1240                        element Sensor_Name { 
     1241                element Short_Name {data($DepDPTRecord/moles:abbreviation)}, 
     1242                element Long_Name {data($DepDPTRecord/moles:name)} 
    12001243            }, 
    1201     for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID) 
    1202     return  
    1203         element Source_Name { 
    1204             for $DepObsStnAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:abbreviation)) 
    1205                 return element Short_Name {data($DepObsStnAbbrev)}, 
    1206             for $DepObsStnName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:name)) 
    1207                 return element Long_Name {data($DepObsStnName)} 
     1244    for $DepObsStnRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     1245    for $DepObsStnLocal in distinct-values(($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID[moles:repositoryIdentifier=$DepObsStnRepository]/moles:localIdentifier)) 
     1246    let $DepObsStnRecord := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:repositoryIdentifier=$DepObsStnRepository  and moles:localIdentifier=$DepObsStnLocal]] 
     1247                return element Source_Name { 
     1248                element Short_Name {data($DepObsStnRecord/moles:abbreviation)}, 
     1249                element Long_Name {data($DepObsStnRecord/moles:name)} 
    12081250            }, 
    1209     for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:DateRange) 
     1251    for $TemporalRange in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/(moles:dgTemporalCoverage | moles:dgSpatioTemporalCoverage/moles:dgSpatioTemporalRange/moles:dgTemporalCoverage)/moles:DateRange 
    12101252        return  
    12111253            element Temporal_Coverage 
     
    12141256                element End_Date {data($TemporalRange/moles:DateRangeEnd)} 
    12151257                }, 
    1216     for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_chronostratigraphic_valids, moles:dgValidTermID/moles:ParentListID)]/moles:dgValidTerm) 
     1258    for $TemporalTerm in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/(moles:dgTemporalCoverage | moles:dgSpatioTemporalCoverage/moles:dgSpatioTemporalRange/moles:dgTemporalCoverage)/moles:dgChronostratigraphicTerm[voclib:spot-vocab($voclib:gcmd_chronostratigraphic_valids, moles:dgValidTermID/moles:ParentListID)]/moles:dgValidTerm 
    12171259        return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}},  
    12181260    for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure) 
    12191261        return element Data_Set_Progress {data($Data_Set_Progress)}, 
    1220     for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox) 
     1262    for $BoundingBox in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/(moles:dgSpatialCoverage | moles:dgSpatioTemporalCoverage/moles:dgSpatioTemporalRange/moles:dgSpatialCoverage)/moles:BoundingBox 
    12211263    return  
    12221264        element Spatial_Coverage { 
     
    12261268                element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)} 
    12271269            }, 
    1228     for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_location_valids, moles:dgValidTermID/moles:ParentListID)]) 
     1270    for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/(moles:dgSpatialCoverage | moles:dgSpatioTemporalCoverage/moles:dgSpatioTemporalRange/moles:dgSpatialCoverage)/moles:dgArea[voclib:spot-vocab($voclib:gcmd_location_valids, moles:dgValidTermID/moles:ParentListID)]) 
    12291271        return element Location {data($Location/moles:dgValidTerm)},  
    1230     for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID) 
     1272    for $DepActRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID/moles:repositoryIdentifer) 
     1273    for $DepActLocal in  distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID[moles:repositoryIdentifer=$DepActRepository]/moles:localIdentifer)   
     1274    let $DepActRecord := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:repositoryIdentifier=$DepActRepository and moles:localIdentifier=$DepActLocal]] 
    12311275    return  
    12321276        element Project { 
    1233             for $DepActAbbrev in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:abbreviation) 
    1234                 return  
    1235                     element Short_Name {data($DepActAbbrev)}, 
    1236             for $DepActName in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:name) 
    1237                 return  
    1238                     element Long_Name {data($DepActName)} 
     1277                    element Short_Name {data($DepActRecord/abbreviation)}, 
     1278                    element Long_Name {data($DepActRecord/name)} 
    12391279            }, 
    12401280    if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then  
     
    14301470            element Future_DIF_Review_Date {data($DE/moles:dgMetadataProvenance/moles:RecordReview/moles:ReviewDate)} 
    14311471    else () 
    1432         }''' 
     1472        } 
     1473''' 
    14331474         
    1434 DublinCoreDEQuery='''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     1475DublinCoreDEQuery=''' 
     1476import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    14351477import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
    14361478declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
    14371479declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    14381480declare namespace dc='http://purl.org/dc/elements/1.1/'; 
    1439 declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc'; 
     1481declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc/'; 
     1482(: 
     1483declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     1484declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     1485declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
     1486:) 
     1487 
    14401488declare variable $targetCollection as xs:string {'TargetCollection'}; 
    14411489declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
     
    14441492for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[ 
    14451493exists('dgDataEntity')  
    1446 and dgMetadataID/schemeIdentifier='NDG-B0'  
    14471494and dgMetadataID/repositoryIdentifier=$repositoryIdentifier 
    14481495and dgMetadataID/localIdentifier=$localIdentifier] 
     
    14531500    element dc:type {'Dataset'}, 
    14541501    element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, $utillib:moles_id_separator, 'DC', $utillib:moles_id_separator, $DE/dgMetadataID/localIdentifier)}, 
     1502    for $identifiers in $DE/(dgMetadataDescription/descriptionSection/descriptionOnlineReference | abstract/abstractOnlineReference)[ 
     1503        exists(dgReferenceClass/dgValidTermID/ParentListID) 
     1504        and 
     1505        voclib:spot-vocab($voclib:ndg_online_reference_classes_vocab, dgReferenceClass/dgValidTermID/ParentListID)  
     1506        and 
     1507        dgReferenceClass/dgValidTerm='DataPage'] 
     1508    return element dc:identifier {data($identifiers/dgSimpleLink/URI)}, 
    14551509    element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)}, 
    14561510    element dc:date 
     
    14581512        if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then 
    14591513            for $updatedate in ($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate) 
    1460                 order by xs:dateTime($updatedate) 
     1514                order by xs:date($updatedate) 
    14611515            return data($updatedate[1]) 
    14621516        else 
     
    15131567                    (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName)))) 
    15141568                else ('empty content') 
    1515             } 
    1516 }  (: </oai_dc:dc> :)''' 
     1569} 
     1570}  (: </oai_dc:dc> :) 
     1571''' 
    15171572 
    15181573MDIPQuery='''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     
    16071662    } 
    16081663''' 
    1609  
    1610  
Note: See TracChangeset for help on using the changeset viewer.