1 | # This version using xqueries from rev 1914 of |
---|
2 | # TI07-MOLES/trunk/JavaCode/returnmolesxmldb/ndg/services/returnmoles/Main.java |
---|
3 | # Update DIF/DC queries |
---|
4 | listingQuery=''' |
---|
5 | declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $DE |
---|
6 | in |
---|
7 | collection('/db/ndg_B_metadata')/dgMetadata/dgMetadataRecord[exists(dgDataEntity)] return |
---|
8 | <dgMetadataRecord>{$DE/dgMetadataID/repositoryIdentifier} |
---|
9 | {$DE/dgMetadataID/localIdentifier}<fileName>{util:document-name($DE)}</fileName></dgMetadataRecord> |
---|
10 | ''' |
---|
11 | |
---|
12 | ObjectTypeQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $Obj in collection('/db/ndg_B_metadata')/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>''' |
---|
13 | |
---|
14 | StubBDEQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles/dataentity';declare namespace moles='http://ndg.nerc.ac.uk/moles';declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions';declare function f:strip-namespace($e as element()) as element(){element {QName('', local-name($e))}{let $parent :=$e let $childcount := count($parent/*) return if ($childcount>0) then for $child in ($e/*) return f:strip-namespace($child) else (data($e))}};declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRAct in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRAct/moles:dgMetadataID),($SRAct/moles:dgMetadataDescription),($SRAct/moles:name),($SRAct/moles:abbreviation),element dgActivity {if (exists($SRAct/*/moles:dgActivityDataCollection)) then ($SRAct/*/moles:dgActivityDataCollection) else if (exists($SRAct/*/moles:dgActivityDataProject)) then ($SRAct/*/moles:dgActivityDataProject) else if (exists($SRAct/*/dgActivityDataCampaign)) then ($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) else ($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),($SRAct/moles:dgActivity/moles:dgActivityCoverage),($SRAct/moles:dgActivity/moles:dgActivityDuration)}})};declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRDE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRDE/moles:dgMetadataID),($SRDE/moles:dgMetadataDescription),($SRDE/moles:name),($SRDE/moles:abbreviation),element dgDataEntity {($SRDE/moles:dgDataEntity/moles:dgDataSetType),($SRDE/moles:dgDataEntity/moles:dgDataGranule),($SRDE/moles:dgDataEntity/moles:dgDataSummary)}})};declare function f:return-stub-dpt($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRDPT in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$SRDPT/moles:dgMetadataID,$SRDPT/moles:dgMetadataDescription,$SRDPT/moles:name,$SRDPT/moles:abbreviation,$SRDPT/moles:logos,element dgDataProductionTool {$SRDPT/moles:dgDataProductionTool/moles:contactDetails,if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then $SRDPT/moles:dgDataProductionTool/moles:dgModel else (),if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then $SRDPT/moles:dgDataProductionTool/moles:dgInstrument else ()}})};declare function f:return-stub-obsstn($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRObsStn in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRObsStn/moles:dgMetadataID),($SRObsStn/moles:dgMetadataDescription),($SRObsStn/moles:name),($SRObsStn/moles:abbreviation),element dgObservationStation {($SRObsStn/moles:dgObservationStation/moles:contactDetails),if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then element dgStationaryPlatform {$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position,if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} else ()} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then $SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform else ()}})};declare function f:return-stub-person($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $person in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($person/moles:name),($person/moles:contactDetails),($person/moles:dgMetadataID)})};declare function f:return-stub-organisation($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid])return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $org in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$org/moles:dgMetadataID,$org/moles:name,$org/moles:abbreviation,$org/moles:contactDetails,$org/moles:logos})};for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[exists(moles:dgDataEntity)and moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier='RepositoryID' and moles:localIdentifier='LocalID']] return f:strip-namespace(element dgMetadataRecord {element dgMetadataID {element schemeIdentifier {'NDG-B1'},$DE/moles:dgMetadataID/moles:repositoryIdentifier,$DE/moles:dgMetadataID/moles:localIdentifier},$DE/moles:dgMetadataDescription,$DE/moles:name,$DE/moles:abbreviation,element dgDataEntity {$DE/moles:dgDataEntity/moles:dgDataSetType,$DE/moles:dgDataEntity/moles:dgDataObjectType,$DE/moles:dgDataEntity/moles:dgDataGranule,$DE/moles:dgDataEntity/moles:dgDataSummary,element dgDataRoles {if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgMetadataID)) then element dgDataCreator {$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgMetadataID,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:roleName,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:abbreviation,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:contactDetails,for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder order by $DataCreatorRole/moles:startDate empty least, $DataCreatorRole/moles:endDate empty least return element dgRoleHolder {if (exists($DataCreatorRole/moles:dgOrganisationID)) then f:return-stub-organisation('organisation', data($DataCreatorRole/moles:dgOrganisationID/moles:repositoryIdentifier), data($DataCreatorRole/moles:dgOrganisationID/moles:localIdentifier)) else if (exists($DataCreatorRole/moles:dgPersonID)) then f:return-stub-person('person', string($DataCreatorRole/moles:dgPersonID/moles:repositoryIdentifier), string($DataCreatorRole/moles:dgPersonID/moles:localIdentifier)) else (),$DataCreatorRole/moles:startDate,$DataCreatorRole/moles:endDate,$DataCreatorRole/moles:localName}} else (),if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgMetadataID)) then element dgDataCurator {$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgMetadataID,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:roleName,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:abbreviation,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:contactDetails,for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder order by $DataCuratorRole/moles:startDate empty least, $DataCuratorRole/moles:endDate empty least return element dgRoleHolder {if (exists($DataCuratorRole/moles:dgOrganisationID)) then f:return-stub-organisation('organisation', data($DataCuratorRole/moles:dgOrganisationID/moles:repositoryIdentifier), data($DataCuratorRole/moles:dgOrganisationID/moles:localIdentifier)) else if (exists($DataCuratorRole/moles:dgPersonID)) then f:return-stub-person('person', string($DataCuratorRole/moles:dgPersonID/moles:repositoryIdentifier), string($DataCuratorRole/moles:dgPersonID/moles:localIdentifier)) else (),$DataCuratorRole/moles:startDate,$DataCuratorRole/moles:endDate,$DataCuratorRole/moles:localName}} else (),if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataOtherRoles/moles:dgMetadataID)) then element dgDataOtherRoles {$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataOtherRoles/moles:dgMetadataID,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataOtherRoles/moles:roleName,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataOtherRoles/moles:abbreviation,$DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataOtherRoles/moles:contactDetails,for $DataOtherRolesRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataOtherRoles/moles:dgRoleHolder order by $DataOtherRolesRole/moles:startDate empty least, $DataOtherRolesRole/moles:endDate empty least return element dgRoleHolder {if (exists($DataOtherRolesRole/moles:dgOrganisationID)) then f:return-stub-organisation('organisation', data($DataOtherRolesRole/moles:dgOrganisationID/moles:repositoryIdentifier), data($DataOtherRolesRole/moles:dgOrganisationID/moles:localIdentifier)) else if (exists($DataOtherRolesRole/moles:dgPersonID)) then f:return-stub-person('person', string($DataOtherRolesRole/moles:dgPersonID/moles:repositoryIdentifier), string($DataOtherRolesRole/moles:dgPersonID/moles:localIdentifier)) else (),$DataOtherRolesRole/moles:startDate,$DataOtherRolesRole/moles:endDate,$DataOtherRolesRole/moles:localName}} else ()},for $RelDep in $DE/moles:dgDataEntity/moles:RelatedDeployment return element RelatedDeployment {$RelDep/moles:DateStart,$RelDep/moles:DateEnd,$RelDep/moles:dgMetadataID,f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)),f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)),f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)),$RelDep/moles:Coverage},for $RelatedDataEntity in $DE/moles:dgDataEntity/moles:dgRelatedDataEntity return element relateddataentity {element relation {$RelatedDataEntity/moles:RelationID/moles:dgValidTerm,$RelatedDataEntity/moles:RelationID/moles:dgValidTermID},f:return-stub-dataentity('dataentity', data($RelatedDataEntity/(moles:RelatedDataEntityID | moles:RelatedDataGranuleID)/moles:repositoryIdentifier), data($RelatedDataEntity/(moles:RelatedDataEntityID | moles:RelatedDataGranuleID)/moles:localIdentifier))}},for $strkwrd in $DE/moles:dgStructuredKeyword return $strkwrd,if (exists($DE/moles:dgMetadataProvenance)) then $DE/moles:dgMetadataProvenance else (),if (exists($DE/moles:dgMetadataSecurity)) then $DE/moles:dgMetadataSecurity else ()})''' |
---|
15 | |
---|
16 | StubBActQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles/activity'; declare namespace moles='http://ndg.nerc.ac.uk/moles'; declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; declare function f:strip-namespace($e as element()) as element() {element {QName('', local-name($e))} {let $parent :=$e let $childcount := count($parent/*) return if ($childcount>0) then for $child in ($e/*) return f:strip-namespace($child) else (data($e))}} ; declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element() {let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'}, element repositoryIdentifier {$repid}, element localIdentifier {$locid}} else (for $SRAct in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRAct/moles:dgMetadataID), ($SRAct/moles:dgMetadataDescription), ($SRAct/moles:name), ($SRAct/moles:abbreviation), element dgActivity {if (exists($SRAct/*/moles:dgActivityDataCollection)) then ($SRAct/*/moles:dgActivityDataCollection) else if (exists($SRAct/*/moles:dgActivityDataProject)) then ($SRAct/*/moles:dgActivityDataProject) else if (exists($SRAct/*/dgActivityDataCampaign)) then ($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) else ($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation), ($SRAct/moles:dgActivity/moles:dgActivityCoverage), ($SRAct/moles:dgActivity/moles:dgActivityDuration)}})};declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element() {let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'}, element repositoryIdentifier {$repid}, element localIdentifier {$locid}} else (for $SRDE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRDE/moles:dgMetadataID), ($SRDE/moles:dgMetadataDescription), ($SRDE/moles:name), ($SRDE/moles:abbreviation), element dgDataEntity {($SRDE/moles:dgDataEntity/moles:dgDataSetType), ($SRDE/moles:dgDataEntity/moles:dgDataGranule), ($SRDE/moles:dgDataEntity/moles:dgDataSummary)}})};declare function f:return-stub-dpt($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element() {let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'}, element repositoryIdentifier {$repid}, element localIdentifier {$locid}} else (for $SRDPT in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$SRDPT/moles:dgMetadataID, $SRDPT/moles:dgMetadataDescription, $SRDPT/moles:name, $SRDPT/moles:abbreviation, $SRDPT/moles:logos, element dgDataProductionTool {$SRDPT/moles:dgDataProductionTool/moles:contactDetails, if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then $SRDPT/moles:dgDataProductionTool/moles:dgModel else (), if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then $SRDPT/moles:dgDataProductionTool/moles:dgInstrument else ()}})}; declare function f:return-stub-obsstn($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element() {let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'}, element repositoryIdentifier {$repid}, element localIdentifier {$locid}} else (for $SRObsStn in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRObsStn/moles:dgMetadataID), ($SRObsStn/moles:dgMetadataDescription), ($SRObsStn/moles:name), ($SRObsStn/moles:abbreviation), element dgObservationStation {($SRObsStn/moles:dgObservationStation/moles:contactDetails), if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then element dgStationaryPlatform {$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} else ()} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then $SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform else ()}})};declare function f:return-stub-person($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element() {let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'}, element repositoryIdentifier {$repid}, element localIdentifier {$locid}} else (for $person in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($person/moles:name), ($person/moles:contactDetails), ($person/moles:dgMetadataID)})}; declare function f:return-stub-organisation($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element() {let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'}, element repositoryIdentifier {$repid}, element localIdentifier {$locid}} else (for $org in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$org/moles:dgMetadataID, $org/moles:name, $org/moles:abbreviation, $org/moles:contactDetails, $org/moles:logos})};for $Act in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgActivity!='' and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID' and moles:dgMetadataID/moles:localIdentifier='LocalID'] return f:strip-namespace(element dgMetadataRecord {element dgMetadataID {element schemeIdentifier {'NDG-B1'}, (element repositoryIdentifier {data($Act/moles:dgMetadataID/moles:repositoryIdentifier)}), element localIdentifier {data($Act/moles:dgMetadataID/moles:localIdentifier)}}, $Act/moles:dgMetadataDescription, $Act/moles:name, $Act/moles:abbreviation, element dgActivity {for $RelatedActivities in $Act/dgActivity/moles:relatedActivity return element relatedActivity {$RelatedActivities/moles:activityRelation, f:return-stub-activity('activity', data($RelatedActivities/moles:relatedActivityID/moles:repositoryIdentifier), data($RelatedActivities/moles:relatedActivityID/moles:localIdentifier))},if (exists($Act/moles:dgActivity/moles:dgActivityDataCollection)) then ($Act/moles:dgActivity/moles:dgActivityDataCollection) else if (exists($Act/moles:dgActivity/moles:dgActivityDataProject)) then ($Act/moles:dgActivity/moles:dgActivityDataProject) else if (exists($Act/moles:dgActivity/moles:dgActivityDataInvestigation)) then ($Act/moles:dgActivity/moles:dgActivityDataInvestigation) else if (exists($Act/moles:dgActivity/moles:dgActivityDataCampaign)) then ($Act/moles:dgActivity/moles:dgActivityDataCampaign) else (), element dgActivityRole {element dgInvestigator {element dgPrincipalInvestigator {($Act/moles:dgActivity/moles:dgActivityRole/moles:dgInvestigator/moles:dgPrincipalInvestigator/moles:dgMetadataID), ($Act/moles:dgActivity/moles:dgActivityRole/moles:dgInvestigator/moles:dgPrincipalInvestigator/moles:roleName), ($Act/moles:dgActivity/moles:dgActivityRole/moles:dgInvestigator/moles:dgPrincipalInvestigator/moles:abbreviation), ($Act/moles:dgActivity/moles:dgActivityRole/moles:dgInvestigator/moles:dgPrincipalInvestigator/moles:contactDetails), for $PIRole in $Act/moles:dgActivity/moles:dgActivityRole/moles:dgInvestigator/moles:dgPrincipalInvestigator/moles:dgRoleHolder order by $PIRole/moles:startDate empty least, $PIRole/moles:endDate empty least return element dgRoleHolder {if (exists($PIRole/moles:dgOrganisationID)) then f:return-stub-organisation('organisation', data($PIRole/moles:dgOrganisationID/moles:repositoryIdentifier), data($PIRole/moles:dgOrganisationID/moles:localIdentifier)) else if (exists($PIRole/moles:dgPersonID)) then f:return-stub-person('person', string($PIRole/moles:dgPersonID/moles:repositoryIdentifier), string($PIRole/moles:dgPersonID/moles:localIdentifier)) else (), ($PIRole/moles:startDate), if (exists($PIRole/moles:endDate)) then ($PIRole/moles:endDate) else (), if (exists($PIRole/moles:localName)) then ($PIRole/moles:localName) else ()}},for $CI in $Act/moles:dgActivity/moles:dgActivityRole/moles:dgInvestigator/moles:dgCoInvestigator return element dgCoInvestigator {($CI/moles:dgMetadataID), ($CI/moles:roleName), ($CI/moles:abbreviation), ($CI/moles:contactDetails), for $CIRole in $CI/moles:dgRoleHolder order by $CIRole/moles:startDate empty least, $CIRole/moles:endDate empty least return element dgRoleHolder {if (exists(CIRole/moles:dgOrganisationID)) then f:return-stub-organisation('organisation', data($CIRole/moles:dgOrganisationID/moles:repositoryIdentifier), data($CIRole/moles:dgOrganisationID/moles:localIdentifier)) else if (exists($CIRole/moles:dgPersonID)) then f:return-stub-person('person', string($CIRole/moles:dgPersonID/moles:repositoryIdentifier), string($CIRole/moles:dgPersonID/moles:localIdentifier)) else (), ($CIRole/moles:startDate), if (exists($CIRole/moles:endDate)) then ($CIRole/moles:endDate) else (), if (exists($CIRole/moles:localName)) then ($CIRole/moles:localName) else ()}}},if (exists($Act/moles:dgActivity/moles:dgActivityRole/moles:dgTechnicalContact)) then (element dgTechnicalContact {($Act/moles:dgActivity/moles:dgActivityRole/moles:dgTechnicalContact/moles:dgMetadataID), ($Act/moles:dgActivity/moles:dgActivityRole/moles:dgTechnicalContact/moles:roleName), ($Act/moles:dgActivity/moles:dgActivityRole/moles:dgTechnicalContact/moles:abbreviation), ($Act/moles:dgActivity/moles:dgActivityRole/moles:dgTechnicalContact/moles:contactDetails), for $TechConRole in $Act/moles:dgActivity/moles:dgActivityRole/moles:dgTechnicalContact/moles:dgRoleHolder order by $TechConRole/moles:startDate empty least, $TechConRole/moles:endDate empty least return element dgRoleHolder {if (exists($TechConRole/moles:dgOrganisationID)) then f:return-stub-organisation('organisation', data($TechConRole/moles:dgOrganisationID/moles:repositoryIdentifier), data($TechConRole/moles:dgOrganisationID/moles:localIdentifier)) else if (exists($TechConRole/moles:dgPersonID)) then f:return-stub-person('person', string($TechConRole/moles:dgPersonID/moles:repositoryIdentifier), string($TechConRole/moles:dgPersonID/moles:localIdentifier)) else (), ($TechConRole/moles:startDate), if (exists($TechConRole/moles:endDate)) then ($TechConRole/moles:endDate) else (), if (exists($TechConRole/moles:localName)) then ($TechConRole/moles:localName) else ()}}) else (),if (exists($Act/dgActivity/dgActivityRole/dgProjectManager)) then (element dgProjectManager {($Act/dgActivity/dgActivityRole/dgProjectManager/dgMetadataID), ($Act/dgActivity/dgActivityRole/dgProjectManager/roleName), ($Act/dgActivity/dgActivityRole/dgProjectManager/abbreviation), ($Act/dgActivity/dgActivityRole/dgProjectManager/contactDetails), for $PMRole in $Act/dgActivity/dgActivityRole/dgProjectManager/dgRoleHolder order by $PMRole/startDate empty least, $PMRole/endDate empty least return element dgRoleHolder {if (exists($PMRole/moles:dgOrganisationID)) then f:return-stub-organisation('organisation', data($PMRole/moles:dgOrganisationID/moles:repositoryIdentifier), data($PMRole/moles:dgOrganisationID/moles:localIdentifier)) else if (exists($PMRole/moles:dgPersonID)) then f:return-stub-person('person', string($PMRole/moles:dgPersonID/moles:repositoryIdentifier), string($PMRole/moles:dgPersonID/moles:localIdentifier)) else (), ($PMRole/startDate), if (exists($PMRole/moles:endDate)) then ($PMRole/moles:endDate) else (), if (exists($PMRole/moles:localName)) then ($PMRole/moles:localName) else ()}}) else ()},for $RelDep in $Act/moles:dgActivity/moles:ActivityDeployment return element ActivityDeployment {($RelDep/moles:DateStart), if (exists($RelDep/moles:DateEnd)) then ($RelDep/moles:DateEnd) else (), ($RelDep/moles:dgMetadataID), f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)), f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord where $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier and $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier return f:return-stub-dataentity('dataentity', data($DE/moles:dgMetadataID/moles:repositoryIdentifier), data($DE/moles:dgMetadataID/moles:localIdentifier))}, (: </ActivityDeployment> :) if (exists($Act/dgActivityCoverage)) then ($Act/dgActivityCoverage) else (), if (exists($Act/dgActivityDuration)) then ($Act/dgActivityDuration) else ()} ,for $strkwrd in $Act/moles:dgStructuredKeyword return $strkwrd, if (exists($Act/moles:dgMetadataProvenance)) then $Act/moles:dgMetadataProvenance else (), if (exists($Act/moles:dgMetadataSecurity)) then $Act/moles:dgMetadataSecurity else ()})''' |
---|
17 | |
---|
18 | StubBDPTQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles/dataproductiontool';declare namespace moles='http://ndg.nerc.ac.uk/moles';declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions';declare function f:strip-namespace($e as element()) as element(){element {QName('', local-name($e))}{let $parent :=$e let $childcount := count($parent/*) return if ($childcount>0) then for $child in ($e/*) return f:strip-namespace($child) else (data($e))}};declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRAct in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRAct/moles:dgMetadataID),($SRAct/moles:dgMetadataDescription),($SRAct/moles:name),($SRAct/moles:abbreviation),element dgActivity {if (exists($SRAct/*/moles:dgActivityDataCollection)) then ($SRAct/*/moles:dgActivityDataCollection) else if (exists($SRAct/*/moles:dgActivityDataProject)) then ($SRAct/*/moles:dgActivityDataProject) else if (exists($SRAct/*/dgActivityDataCampaign)) then ($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) else ($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),($SRAct/moles:dgActivity/moles:dgActivityCoverage),($SRAct/moles:dgActivity/moles:dgActivityDuration)}})};declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRDE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRDE/moles:dgMetadataID),($SRDE/moles:dgMetadataDescription),($SRDE/moles:name),($SRDE/moles:abbreviation),element dgDataEntity {($SRDE/moles:dgDataEntity/moles:dgDataSetType),($SRDE/moles:dgDataEntity/moles:dgDataGranule),($SRDE/moles:dgDataEntity/moles:dgDataSummary)}})};declare function f:return-stub-dpt($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}}else (for $SRDPT in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$SRDPT/moles:dgMetadataID,$SRDPT/moles:dgMetadataDescription,$SRDPT/moles:name,$SRDPT/moles:abbreviation,$SRDPT/moles:logos,element dgDataProductionTool {$SRDPT/moles:dgDataProductionTool/moles:contactDetails,if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then $SRDPT/moles:dgDataProductionTool/moles:dgModel else (),if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then $SRDPT/moles:dgDataProductionTool/moles:dgInstrument else ()}})};declare function f:return-stub-obsstn($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRObsStn in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRObsStn/moles:dgMetadataID),($SRObsStn/moles:dgMetadataDescription),($SRObsStn/moles:name),($SRObsStn/moles:abbreviation),element dgObservationStation {($SRObsStn/moles:dgObservationStation/moles:contactDetails),if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then element dgStationaryPlatform {$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position,if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} else ()} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then $SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform else ()}})};declare function f:return-stub-person($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $person in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name}{($person/moles:name),($person/moles:contactDetails),($person/moles:dgMetadataID)})};declare function f:return-stub-organisation($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $org in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$org/moles:dgMetadataID,$org/moles:name,$org/moles:abbreviation,$org/moles:contactDetails,$org/moles:logos})};for $DPT in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataProductionTool!='' and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID' and moles:dgMetadataID/moles:localIdentifier='LocalID'] return f:strip-namespace(element dgMetadataRecord {$DPT/dgMetadataID,element dgMetadataID {element schemeIdentifier {'NDG-B1'},$DPT/moles:dgMetadataID/moles:repositoryIdentifier,$DPT/moles:dgMetadataID/moles:localIdentifier},$DPT/moles:dgMetadataDescription,$DPT/moles:name,$DPT/moles:abbreviation,element dgDataProductionTool {$DPT/moles:contactDetails,if (exists($DPT/moles:dgModel)) then $DPT/moles:dgModel else $DPT/moles:dgInstrument,if (exists($DPT/moles:dgDPTRoles)) then element dgDPTRoles {'Roles are available, and will be added soon'} else(),for $RelDep in $DPT/moles:dgDataProductionTool/moles:DPTDeployment return element DPTDeployment {$RelDep/moles:DateStart,$RelDep/moles:DateEnd,$RelDep/moles:dgMetadataID,f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)),f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)),for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord where $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier and $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier return f:return-stub-dataentity('dataentity', data($DE/moles:dgMetadataID/moles:repositoryIdentifier), data($DE/moles:dgMetadataID/moles:localIdentifier)),$RelDep/moles:Coverage}},for $strkwrd in $DPT/moles:dgStructuredKeyword return $strkwrd,if (exists($DPT/moles:dgMetadataProvenance)) then $DPT/moles:dgMetadataProvenance else (),if (exists($DPT/moles:dgMetadataSecurity)) then $DPT/moles:dgMetadataSecurity else ()})''' |
---|
19 | |
---|
20 | StubBObsStnQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles/observationstation';declare namespace moles='http://ndg.nerc.ac.uk/moles';declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions';declare function f:strip-namespace($e as element()) as element(){element {QName('', local-name($e))}{let $parent :=$e let $childcount := count($parent/*) return if ($childcount>0) then for $child in ($e/*) return f:strip-namespace($child) else (data($e))}};declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}}else (for $SRAct in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRAct/moles:dgMetadataID),($SRAct/moles:dgMetadataDescription),($SRAct/moles:name),($SRAct/moles:abbreviation),element dgActivity {if (exists($SRAct/*/moles:dgActivityDataCollection)) then ($SRAct/*/moles:dgActivityDataCollection) else if (exists($SRAct/*/moles:dgActivityDataProject)) then ($SRAct/*/moles:dgActivityDataProject) else if (exists($SRAct/*/dgActivityDataCampaign)) then ($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) else ($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),($SRAct/moles:dgActivity/moles:dgActivityCoverage),($SRAct/moles:dgActivity/moles:dgActivityDuration)}})};declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRDE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRDE/moles:dgMetadataID),($SRDE/moles:dgMetadataDescription),($SRDE/moles:name),($SRDE/moles:abbreviation),element dgDataEntity {($SRDE/moles:dgDataEntity/moles:dgDataSetType),($SRDE/moles:dgDataEntity/moles:dgDataGranule),($SRDE/moles:dgDataEntity/moles:dgDataSummary)}})};declare function f:return-stub-dpt($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRDPT in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$SRDPT/moles:dgMetadataID,$SRDPT/moles:dgMetadataDescription,$SRDPT/moles:name,$SRDPT/moles:abbreviation,$SRDPT/moles:logos,element dgDataProductionTool {$SRDPT/moles:dgDataProductionTool/moles:contactDetails,if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then $SRDPT/moles:dgDataProductionTool/moles:dgModel else (),if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then $SRDPT/moles:dgDataProductionTool/moles:dgInstrument else ()}})};declare function f:return-stub-obsstn($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $SRObsStn in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {($SRObsStn/moles:dgMetadataID),($SRObsStn/moles:dgMetadataDescription),($SRObsStn/moles:name),($SRObsStn/moles:abbreviation),element dgObservationStation {($SRObsStn/moles:dgObservationStation/moles:contactDetails),if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then element dgStationaryPlatform {$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position,if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} else ()} else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then $SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform else ()}})};declare function f:return-stub-person($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $person in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgPerson[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name}{($person/moles:name),($person/moles:contactDetails),($person/moles:dgMetadataID)})};declare function f:return-stub-organisation($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element(){let $found := count(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid]) return if ($found = 0) then element {$out-element-name} {element error {'not found'},element repositoryIdentifier {$repid},element localIdentifier {$locid}} else (for $org in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgOrganisation[moles:dgMetadataID/moles:repositoryIdentifier=$repid and moles:dgMetadataID/moles:localIdentifier=$locid] return element {$out-element-name} {$org/moles:dgMetadataID,$org/moles:name,$org/moles:abbreviation,$org/moles:contactDetails,$org/moles:logos})};for $ObsStn in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgObservationStation!='' and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID' and moles:dgMetadataID/moles:localIdentifier='LocalID'] return f:strip-namespace(element dgMetadataRecord {element dgMetadataID {element schemeIdentifier {'NDG-B1',$ObsStn/moles:dgMetadataID/moles:repositoryIdentifier,$ObsStn/moles:dgMetadataID/moles:localIdentifier},$ObsStn/moles:dgMetadataDescription,$ObsStn/moles:name,$ObsStn/moles:abbreviation,element dgObservationStation {$ObsStn/moles:dgObservationStation/moles:contactDetails,if (exists($ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then element dgStationaryPlatform {$ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position,if (exists($ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring)) then element dgMooring {$ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring/moles:dateStart,$ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring/moles:dateEnd,for $DepositingCruise in $ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring/moles:DepositingCruise return f:return-stub-activity('depositingcruise', data($DepositingCruise/moles:dgMetadataID/moles:repositoryIdentifier), data($DepositingCruise/moles:dgMetadataID/moles:localIdentifier)),if (exists($ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring/moles:dgStationGrouping)) then for $StationGrouping in $ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring/dgStationGrouping return f:return-stub-obsstn('stationgrouping', data($StationGrouping/moles:dgMetadataID/moles:repositoryIdentifier), data($StationGrouping/moles:dgMetadataID/moles:localIdentifier)) else ()} else if (exists($ObsStn/dgObservationStation/dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {element dgGroupedStations {if (exists($ObsStn/dgObservationStation/dgStationaryPlatform/dgStationGroup/dgGroupedStations)) then for $GroupedStation in $ObsStn/dgObservationStation/dgStationaryPlatform/dgStationGroup/dgGroupedStation/dgGroupedStations return f:return-stub-obsstn('dgGroupedStation', data($GroupedStation/moles:dgMetadataID/moles:repositoryIdentifier), data($GroupedStation/moles:dgMetadataID/moles:localIdentifier)) else ()}} else $ObsStn/moles:dgObservationStation/moles:dgLandStation} else $ObsStn/moles:dgObservationStation/moles:dgMovingPlatform},for $RelDep in $ObsStn/moles:dgObservationStation/moles:ObsStationDeployment return element ObsStationDeployment {$RelDep/moles:DateStart,$RelDep/moles:DateEnd,$RelDep/moles:dgMetadataID,f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)),f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)),for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord where $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier and $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier return f:return-stub-dataentity('dataentity', data($DE/moles:dgMetadataID/moles:repositoryIdentifier), data($DE/moles:dgMetadataID/moles:localIdentifier)),$RelDep/moles:Coverage}},for $strkwrd in $ObsStn/moles:dgStructuredKeyword return $strkwrd,if (exists($ObsStn/moles:dgMetadataProvenance)) then $ObsStn/moles:dgMetadataProvenance else (),if (exists($ObsStn/moles:dgMetadataSecurity)) then $ObsStn/moles:dgMetadataSecurity else ()})''' |
---|
21 | |
---|
22 | MOLESQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $Moles in collection('/db/ndg_B_metadata')/dgMetadata/dgMetadataRecord[dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID'] return $Moles''' |
---|
23 | |
---|
24 | DublinCoreDEQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles'; |
---|
25 | declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; |
---|
26 | declare namespace dc='http://purl.org/dc/elements/1.1/'; |
---|
27 | declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc'; |
---|
28 | declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; |
---|
29 | declare variable $gcmd_science_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'}; |
---|
30 | declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'}; |
---|
31 | declare variable $cf_standard_names as xs:string {'http://www.cgd.ucar.edu/cms/eaton/cf-metadata/standard_name.html'}; |
---|
32 | declare variable $iso_topic_list as xs:string {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'}; |
---|
33 | |
---|
34 | for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[dgDataEntity!='' and dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID'] |
---|
35 | return |
---|
36 | element oai_dc:dc { |
---|
37 | attribute xsi:schemaLocation {'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'}, |
---|
38 | element dc:title {string($DE/name)}, |
---|
39 | element dc:type {'Dataset'}, |
---|
40 | element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, ':DC:', $DE/dgMetadataID/localIdentifier)}, |
---|
41 | element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)}, |
---|
42 | element dc:date |
---|
43 | { |
---|
44 | if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then |
---|
45 | for $updatedate in ($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate) |
---|
46 | order by xs:dateTime($updatedate) |
---|
47 | return data($updatedate[1]) |
---|
48 | else |
---|
49 | string($DE/(dgMetadataProvenance | DataProvenance)/RecordCreation/CreatedDate) |
---|
50 | }, |
---|
51 | for $StructuredKeyword in distinct-values($DE/dgStructuredKeyword [dgValidTermID/ParentListID=$cf_standard_names or dgValidTermID/ParentListID=$gcmd_science_valids or dgValidTermID/ParentListID=$gcmd_project_valids or dgValidTermID/ParentListID=$iso_topic_list ]//dgValidTerm) |
---|
52 | order by $StructuredKeyword |
---|
53 | return |
---|
54 | element dc:subject {string($StructuredKeyword)}, |
---|
55 | |
---|
56 | for $StructuredKeyword1 in distinct-values($DE/dgDataEntity/dgDataSummary/dgParameterSummary/dgStdParameterMeasured[dgValidTermID/ParentListID=$cf_standard_names or dgValidTermID/ParentListID=$gcmd_science_valids or dgValidTermID/ParentListID=$gcmd_project_valids]//dgValidTerm) |
---|
57 | order by $StructuredKeyword1 |
---|
58 | return |
---|
59 | element dc:subject {string($StructuredKeyword1)}, |
---|
60 | for $DataCreatorRole in $DE/dgDataEntity/dgDataRoles/dgDataCreator/dgRoleHolder |
---|
61 | order by $DataCreatorRole/startDate empty least |
---|
62 | return |
---|
63 | for $DataCreatorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson) |
---|
64 | [(dgMetadataID/schemeIdentifier='NDG-B0' |
---|
65 | and dgMetadataID/repositoryIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier |
---|
66 | and dgMetadataID/localIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] |
---|
67 | return |
---|
68 | element dc:creator { |
---|
69 | if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then |
---|
70 | (string($DataCreatorRoleHolder/name)) |
---|
71 | else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then |
---|
72 | (string(concat(string($DataCreatorRoleHolder/name/initials), ' ', string($DataCreatorRoleHolder/name/familyName)))) |
---|
73 | else ('empty content') |
---|
74 | }, |
---|
75 | for $DataCuratorRole in $DE/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder[not(exists(endDate)) or endDate=''] |
---|
76 | order by $DataCuratorRole/startDate empty least |
---|
77 | return |
---|
78 | for $DataCuratorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson) |
---|
79 | [(dgMetadataID/schemeIdentifier='NDG-B0' |
---|
80 | and dgMetadataID/repositoryIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier |
---|
81 | and dgMetadataID/localIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] |
---|
82 | return |
---|
83 | element dc:publisher { |
---|
84 | if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then |
---|
85 | (string($DataCuratorRoleHolder/name)) |
---|
86 | else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then |
---|
87 | (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName)))) |
---|
88 | else ('empty content') |
---|
89 | } |
---|
90 | }''' |
---|
91 | |
---|
92 | DIFQuery = '''declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; |
---|
93 | declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; |
---|
94 | declare namespace moles='http://ndg.nerc.ac.uk/moles'; |
---|
95 | declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; |
---|
96 | |
---|
97 | for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ |
---|
98 | exists('moles:dgDataEntity') |
---|
99 | and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' |
---|
100 | and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID' |
---|
101 | and moles:dgMetadataID/moles:localIdentifier='LocalID'] |
---|
102 | return |
---|
103 | element DIF { |
---|
104 | attribute xsi:schemaLocation {'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.4.xsd'}, |
---|
105 | element Entry_ID {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':DIF:', $DE/moles:dgMetadataID/moles:localIdentifier)}, |
---|
106 | element Entry_Title {string($DE/moles:name)}, |
---|
107 | element Data_Set_Citation { |
---|
108 | for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] |
---|
109 | return |
---|
110 | for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' |
---|
111 | and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier |
---|
112 | and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] |
---|
113 | return |
---|
114 | element Data_Creator { |
---|
115 | if (exists($DataCreatorRoleHolder/moles:name/moles:initials)) then |
---|
116 | string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName))) |
---|
117 | else |
---|
118 | string($DataCreatorRoleHolder/moles:abbreviation) |
---|
119 | }, |
---|
120 | element Dataset_Title {string($DE/moles:name)} |
---|
121 | }, |
---|
122 | for $StructuredKeyword in ($DE//(moles:dgStructuredKeyword | moles:dgStdParameterMeasured)[moles:dgValidTermID/moles:ParentListID='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html' and moles:ListLevel = 0]) |
---|
123 | return if (exists($StructuredKeyword/*/moles:dgValidTerm)) then |
---|
124 | element Parameters { |
---|
125 | element Category {string($StructuredKeyword/*/moles:dgValidTerm)}, |
---|
126 | if (exists($StructuredKeyword//moles:dgValidSubterm) |
---|
127 | and $StructuredKeyword//moles:dgValidSubterm != '' |
---|
128 | and $StructuredKeyword//moles:dgValidSubterm != ' ') then |
---|
129 | for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)] |
---|
130 | where exists($Subterm/moles:dgValidSubterm) |
---|
131 | order by $Subterm/moles:ListLevel |
---|
132 | return |
---|
133 | if ($Subterm/moles:ListLevel=1) then element Topic {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} |
---|
134 | else if ($Subterm/moles:ListLevel=2) then element Term {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} |
---|
135 | else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} |
---|
136 | else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} |
---|
137 | else element GCMD_Science_Valid {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} |
---|
138 | else() |
---|
139 | } |
---|
140 | else(), |
---|
141 | for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[moles:dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) |
---|
142 | return |
---|
143 | element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)}, |
---|
144 | for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ |
---|
145 | moles:dgValidTermID/moles:ParentListID!='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html' |
---|
146 | and |
---|
147 | moles:dgValidTermID/moles:ParentListID!='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode' |
---|
148 | ]/moles:dgValidTerm) |
---|
149 | return element Keyword {string($Keyword)}, |
---|
150 | for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID) |
---|
151 | return |
---|
152 | element Sensor_Name { |
---|
153 | for $DepDPTAbbrev in distinct-values((collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:abbreviation)) |
---|
154 | return element Short_Name {data($DepDPTAbbrev)}, |
---|
155 | for $DepDPTName in distinct-values((collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:name)) |
---|
156 | return element Long_Name {data($DepDPTName)} |
---|
157 | }, |
---|
158 | for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID) |
---|
159 | return |
---|
160 | element Source_Name { |
---|
161 | for $DepObsStnAbbrev in distinct-values((collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:abbreviation)) |
---|
162 | return element Short_Name {data($DepObsStnAbbrev)}, |
---|
163 | for $DepObsStnName in distinct-values((collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:name)) |
---|
164 | return element Long_Name {data($DepObsStnName)} |
---|
165 | }, |
---|
166 | for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgDateRange) |
---|
167 | return |
---|
168 | element Temporal_Coverage |
---|
169 | { |
---|
170 | element Start_Date {data($TemporalRange/moles:DateRangeStart)}, |
---|
171 | element End_Date {data($TemporalRange/moles:DateRangeEnd)} |
---|
172 | }, |
---|
173 | for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea/moles:dgValidTerm) |
---|
174 | return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}}, |
---|
175 | for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure) |
---|
176 | return element Data_Set_Progress {data($Data_Set_Progress)}, |
---|
177 | for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox) |
---|
178 | return |
---|
179 | element Spatial_Coverage { |
---|
180 | element Southernmost_Latitude {data($BoundingBox/moles:LimitSouth)}, |
---|
181 | element Northernmost_Latitude {data($BoundingBox/moles:LimitNorth)}, |
---|
182 | element Westernmost_Longitude {data($BoundingBox/moles:LimitWest)}, |
---|
183 | element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)} |
---|
184 | }, |
---|
185 | for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[moles:dgValidTermID/moles:ParentListID='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_locations.html']) |
---|
186 | return element Location {$Location}, |
---|
187 | for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID) |
---|
188 | return |
---|
189 | element Project { |
---|
190 | for $DepActAbbrev in distinct-values(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:abbreviation) |
---|
191 | return |
---|
192 | element Short_Name {data($DepActAbbrev)}, |
---|
193 | for $DepActName in distinct-values(collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:name) |
---|
194 | return |
---|
195 | element Long_Name {data($DepActName)} |
---|
196 | }, |
---|
197 | if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then |
---|
198 | for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule |
---|
199 | return |
---|
200 | element Access_Constraints { |
---|
201 | if (exists($DG/moles:dgGranuleSummary/moles:dgGranuleName)) then |
---|
202 | concat('For data granule ', $DG/moles:dgGranuleSummary/moles:dgGranuleName, ': ') |
---|
203 | else (), |
---|
204 | if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyURL)) then |
---|
205 | concat('See access control policy at ', escape-uri($DG/moles:accessControlPolicy/moles:accessControlPolicyURL, true())) |
---|
206 | else if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyText)) then |
---|
207 | data($DG/moles:accessControlPolicy/moles:accessControlPolicyText) |
---|
208 | else |
---|
209 | for $securityCondition in $DG/moles:accessControlPolicy/moles:dgSecurityCondition |
---|
210 | return |
---|
211 | if (exists($securityCondition/moles:conditionExplanationText)) then |
---|
212 | concat('Effect: ', data($securityCondition/moles:effect), ' - ', data($securityCondition/moles:conditionExplanationText)) |
---|
213 | else concat('Effect: ', data($securityCondition/moles:effect), 'needs ', data($securityCondition/moles:attauthRole), ' from ', data($securityCondition/moles:dgAttributeAuthority)) |
---|
214 | } |
---|
215 | else (), |
---|
216 | if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder)) then |
---|
217 | for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder |
---|
218 | order by $DataCreatorRole/moles:startDate empty least |
---|
219 | return |
---|
220 | for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) |
---|
221 | [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' |
---|
222 | and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:repositoryIdentifier |
---|
223 | and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:localIdentifier)] |
---|
224 | return |
---|
225 | element Originating_Center { |
---|
226 | if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then |
---|
227 | (string($DataCreatorRoleHolder/moles:name)) |
---|
228 | else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then |
---|
229 | (string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName)))) |
---|
230 | else ('empty content') |
---|
231 | } |
---|
232 | else (), |
---|
233 | for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''] |
---|
234 | return |
---|
235 | for $DataCuratorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' |
---|
236 | and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/*/moles:repositoryIdentifier |
---|
237 | and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/*/moles:localIdentifier)] |
---|
238 | return |
---|
239 | element Data_Center { |
---|
240 | element Data_Center_Name { |
---|
241 | element Short_Name { |
---|
242 | if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then |
---|
243 | string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) |
---|
244 | else |
---|
245 | string($DataCuratorRoleHolder/moles:abbreviation) |
---|
246 | }, |
---|
247 | element Long_Name { |
---|
248 | if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then |
---|
249 | string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) |
---|
250 | else string($DataCuratorRoleHolder/moles:name) |
---|
251 | } |
---|
252 | }, |
---|
253 | if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:URI)) then |
---|
254 | element Data_Center_URL {data($DataCuratorRoleHolder/moles:contactDetails/moles:URI)} |
---|
255 | else (), |
---|
256 | for $DGID in $DE/moles:dgDataEntity/moles:dgDataGranule/moles:dataModelID |
---|
257 | return |
---|
258 | element Data_Set_ID {concat($DGID/moles:repositoryIdentifier, ':', $DGID/moles:schemeIdentifier, ':', $DGID/moles:localIdentifier)}, |
---|
259 | element Personnel { |
---|
260 | element Role {'Data Center Contact'}, |
---|
261 | if (exists($DataCuratorRoleHolder/name/knownAs)) then |
---|
262 | element First_Name {string($DataCuratorRoleHolder/moles:name/moles:knownAs)} |
---|
263 | else if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then |
---|
264 | element First_Name {string($DataCuratorRoleHolder/moles:name/moles:initials)} |
---|
265 | else (), |
---|
266 | element Last_Name { |
---|
267 | if (exists($DataCuratorRoleHolder/moles:name/moles:familyName)) then |
---|
268 | string($DataCuratorRoleHolder/moles:name/moles:familyName) |
---|
269 | else string($DataCuratorRoleHolder/moles:name) |
---|
270 | }, |
---|
271 | if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then |
---|
272 | element Email {string($DataCuratorRole/moles:contactDetails/moles:eMail)} |
---|
273 | else |
---|
274 | if (exists($DataCuratorRoleHolder/contactDetails/eMail)) then |
---|
275 | (element Email {string($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}) |
---|
276 | else (), |
---|
277 | if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then |
---|
278 | element Phone {string($DataCuratorRole/moles:contactDetails/moles:telephone)} |
---|
279 | else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then |
---|
280 | element Phone {string($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)} |
---|
281 | else (), |
---|
282 | if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then |
---|
283 | element Fax {string($DataCuratorRole/moles:contactDetails/moles:fax)} |
---|
284 | else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then |
---|
285 | element Fax {string($DataCuratorRoleHolder/moles:contactDetails/moles:fax)} |
---|
286 | else (), |
---|
287 | if (exists($DataCuratorRole/moles:contactDetails/moles:address)) then |
---|
288 | element Contact_Address { |
---|
289 | for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline |
---|
290 | return element Address {data($addressline)}, |
---|
291 | if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then |
---|
292 | element City {string($DataCuratorRole/moles:contactDetails/moles:address/moles:city)} |
---|
293 | else (), |
---|
294 | if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)) then |
---|
295 | element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)} |
---|
296 | else (), |
---|
297 | if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:country)) then |
---|
298 | element Country {string($DataCuratorRole/moles:contactDetails/moles:address/moles:country)} |
---|
299 | else () |
---|
300 | } |
---|
301 | else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address)) then |
---|
302 | element Contact_Address { |
---|
303 | for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline |
---|
304 | return element address {data($addressline)}, |
---|
305 | if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then |
---|
306 | element City {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)} |
---|
307 | else (), |
---|
308 | if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then |
---|
309 | element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:postcode)} |
---|
310 | else (), |
---|
311 | if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)) then |
---|
312 | element Country {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)} |
---|
313 | else () |
---|
314 | } |
---|
315 | else () |
---|
316 | } |
---|
317 | }, |
---|
318 | element Summary {string($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}, |
---|
319 | element Related_URL { |
---|
320 | element URL_Content_Type {'NDG_B_SERVICE'}, |
---|
321 | element URL {data($DE/moles:dgMetadataID/moles:repositoryIdentifier)}, |
---|
322 | element Description {'The NDG service for browsing metadata.'} |
---|
323 | }, |
---|
324 | for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule |
---|
325 | return |
---|
326 | if ($DG/moles:dataModelID/moles:schemeIdentifier='NDG-A0') then |
---|
327 | (element Related_URL { |
---|
328 | element URL_Content_Type {'NDG_A_SERVICE'}, |
---|
329 | if (exists($DG/instance/URI)) then |
---|
330 | element URL {escape-uri($DG/instance/URI, true())} |
---|
331 | else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then |
---|
332 | element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&datasetID=', true())} |
---|
333 | else ($DG/moles:dataModelID/moles:repositoryIdentifier), |
---|
334 | element Description {'The NDG service delivering data via NDG A metadata.'} |
---|
335 | }, |
---|
336 | element Related_URL { |
---|
337 | element URL_Content_Type {'GET DATA > CSML'}, |
---|
338 | if (exists($DG/instance)) then |
---|
339 | element URL {escape-uri($DG/instance/URI, true())} |
---|
340 | else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then |
---|
341 | element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&datasetID=', true())} |
---|
342 | else (), |
---|
343 | element Description {'The NDG service delivering data via NDG A metadata. Additional tag to be more in line with latest version of GCMD valids'} |
---|
344 | }) |
---|
345 | else if ($DG/moles:dataModelID/moles:schemeIdentifier='CDML-0') then |
---|
346 | (element Related_URL { |
---|
347 | element URL_Content_Type {'NDG_A_SERVICE'}, |
---|
348 | if (exists($DG/instance)) then |
---|
349 | element URL {escape-uri($DG/instance/URI, true())} |
---|
350 | else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then |
---|
351 | element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} |
---|
352 | else (), |
---|
353 | element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} |
---|
354 | }, |
---|
355 | element Related_URL { |
---|
356 | element URL_Content_Type {'GET DATA > DX'}, |
---|
357 | if (exists($DG/instance)) then |
---|
358 | element URL {escape-uri($DG/instance/URI, true())} |
---|
359 | else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then |
---|
360 | element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} |
---|
361 | else (), |
---|
362 | element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} |
---|
363 | }) |
---|
364 | else if ($DG/moles:dataModelID/moles:schemeIdentifier='URI') then |
---|
365 | element Related_URL { |
---|
366 | element URL {data($DG/moles:instance/moles:URI)}, |
---|
367 | if (exists($DG/moles:instance/moles:instanceComment)) then |
---|
368 | element Description {data($DG/moles:instance/moles:instanceComment)} |
---|
369 | else |
---|
370 | element Description {'URL to aid in delivering data. Note that this may point directly to the data or, more likely, point to the web site of the curator.'} |
---|
371 | } |
---|
372 | else (), |
---|
373 | for $RelURL_Desc in ($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference) |
---|
374 | return |
---|
375 | element Related_URL { |
---|
376 | element URL {data($RelURL_Desc)}, |
---|
377 | element Description {concat(data($RelURL_Desc/moles:name), ' - ', data($RelURL_Desc/moles:notes))} |
---|
378 | }, |
---|
379 | element Metadata_Name {'[CEOS IDN DIF]'}, |
---|
380 | element Metadata_Version {'9.4'}, |
---|
381 | if (exists($DE/moles:dgMetadataProvenance/moles:RecordCreation)) then |
---|
382 | element DIF_Creation_Date {data($DE/moles:dgMetadataProvenance/moles:RecordCreation/moles:CreatedDate)} |
---|
383 | else (), |
---|
384 | for $MDUpdt in $DE/moles:dgMetadataProvenance/moles:RecordUpdate |
---|
385 | return |
---|
386 | element DIF_Revision_History {concat(data($MDUpdt/moles:UpdateDate), ' - ', data($MDUpdt/moles:UpdateSummary), ' - ', data($MDUpdt/moles:UpdatedBy))}, |
---|
387 | if (exists($DE/moles:dgMetadataProvenance/moles:RecordReview)) then |
---|
388 | element Future_DIF_Review_Date {data($DE/moles:dgMetadataProvenance/moles:RecordReview/moles:ReviewDate)} |
---|
389 | else () |
---|
390 | }''' |
---|
391 | |
---|
392 | ISO19139Query = '''declare default element namespace 'http://www.isotc211.org/2005/gmd'; declare namespace moles='http://ndg.nerc.ac.uk/moles'; declare namespace gco='http://www.isotc211.org/2005/gco'; declare namespace gmd='http://www.isotc211.org/2005/gmd'; declare namespace gml='http://www.opengis.net/gml'; declare namespace xlink='http://www.w3.org/1999/xlink'; declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ exists(moles:dgDataEntity) and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID' and moles:dgMetadataID/moles:localIdentifier='LocalID'] return element MD_Metadata {attribute xsi:schemaLocation {'http://www.isotc211.org/2005/gmd http://www.isotc211.org/2005/gmd/metadataEntity.xsd'}, element fileIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':ISO19115:', $DE/moles:dgMetadataID/moles:localIdentifier)}}, element language {element gmd:LanguageCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English'}}, element hierarchyLevel {element MD_ScopeCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode_dataset'}, 'dataset'}}, for $parent in $DE/moles:dgRelatedDataEntity[moles:RelationID/moles:dgValidTerm='is-part-of'] return element parentIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier)}}, for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''] return for $DataCuratorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/(moles:dgPerson | moles:dgOrganisation)[ moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:repositoryIdentifier and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:localIdentifier] return element contact {element CI_ResponsibleParty {if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then element organisationName {element gco:CharacterString {string($DataCuratorRoleHolder/moles:name)}}else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then element individualName {element gco:CharacterString {string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName)))}}else ('empty content') , element positionName {if (exists($DataCuratorRoleHolder/moles:localName)) then element gco:CharacterString {$DataCuratorRoleHolder/moles:localName}else if (exists($DataCuratorRole/moles:roleName)) then element gco:CharacterString {$DataCuratorRole/moles:roleName}else element gco:CharacterString {'Curator'}}, element contactInfo {element gmd:CI_Contact {if (exists($DataCuratorRole/moles:contactDetails/moles:telephone or $DataCuratorRole/moles:contactDetails/moles:fax or $DataCuratorRoleHolder/moles:contactDetails/moles:telephone or $DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then element phone {element gmd:CI_Telephone {if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then element voice {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:telephone)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element voice {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then element facsimile {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element facsimile {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)}}else () }} else (), element address {element gmd:CI_Address {if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:address/moles:city)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:eMail)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}}else () }}}}, element role {element CI_RoleCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode_custodian'}, if (exists($DataCuratorRole/moles:localName)) then data($DataCuratorRole/moles:localName) else if (exists($DataCuratorRoleHolder/moles:localName)) then data($DataCuratorRoleHolder/moles:localName) else 'Curator' }}}}, element dateStamp {element gco:Date {adjust-date-to-timezone(current-date())}}, element metadataStandardName {element gco:CharacterString {'ISO 19115:2003'}}, element metadataStandardVersion {element gco:CharacterString {'2003'}}, element identificationInfo {element gmd:MD_DataIdentification {element citation {element gmd:CI_Citation {element title {element gco:CharacterString {data($DE/moles:name)}}, if (exists($DE/moles:abbreviation) and not(empty($DE/moles:abbreviation))) then element alternateTitle {element gco:CharacterString {data($DE/moles:abbreviation)}}else (), element date {if (exists($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate)) then element gmd:CI_Date {element date {element gco:Date {adjust-date-to-timezone(data($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate))}}, element dateType {element CI_DateTypeCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/moles:gmxCodelists.xml#CI_DateTypeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode_creation' }, 'Creation'}}}else attribute gco:nilReason {'unknown'}}}}, element abstract {element gco:CharacterString {data($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}}, element language {element gmd:LanguageCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English' }}, for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) return element topicCategory {element gmd:MD_TopicCategoryCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'}, attribute codeListValue {string($ISOTopicCategory/moles:dgValidTerm)}, string($ISOTopicCategory/moles:dgValidTerm)}}, if (exists($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage)) then element extent {element gmd:EX_Extent {(: add bounding boxes:) for $geoBBox in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox return element geographicElement {element EX_GeographicBoundingBox {element westBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitWest)}}, element eastBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitEast)}}, element southBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitSouth)}}, element northBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitNorth)}}}}, for $geoArea in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea return element geographicElement {element EX_GeographicDescription {element geographicIdentifier {element gmd:RS_Identifier {element gco:CharacterString {element code {data(dgArea/dgValidTerm)}}, element gco:CharacterString {element codeSpace {data(dgArea/dgValidTermID/ParentListID)}}}}}}}}else()}}}''' |
---|