Changeset 1832 for TI07-MOLES


Ignore:
Timestamp:
07/12/06 15:21:06 (12 years ago)
Author:
ko23
Message:

Sorted invalid BBs, data creators, paleo-dates, dc keywords, and dates.

Location:
TI07-MOLES/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/DIF/XQuery/DIF2MOLES.xquery

    r1827 r1832  
    1313declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'}; 
    1414declare variable $gcmd_location_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/locations.html'}; 
     15declare variable $gcmd_paleotemporal_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/paleotemporal.html'}; 
    1516declare variable $gcmd_iso_topic_list as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/iso_topic_list.html'}; 
    1617declare variable $cf_standard_names as xs:string {'http://www.cgd.ucar.edu/cms/eaton/cf-metadata/standard_name.html'}; 
     
    1920declare variable $input_repository_local as xs:string {'Input_Repository_LocalID'}; 
    2021declare variable $input_entry_id as xs:string {'Input_Entry_ID'}; 
     22 
     23declare function f:fix-coord($e as element()) as element()  
     24(: Parse a non-decimal co-ordinate element,  parse to see if it's possible to convert to  
     25    a decimal co-ordinate, and do so, else return the rubbish provided :) 
     26{ 
     27if ($e castable as xs:decimal) then   
     28        $e 
     29else 
     30        let $value := substring(data($e), 1, string-length($e)-1) 
     31        let $point := lower-case(data($e)) 
     32        return 
     33        if ($value  castable as xs:decimal) then   
     34                if (ends-with($point, 'n')) then 
     35                        element {name($e)} {$value}  
     36                else if (ends-with($point, 's')) then 
     37                        element {name($e)} {concat('-', $value)}  
     38                else if (ends-with($point, 'e')) then 
     39                        element {name($e)} {$value}  
     40                else if (ends-with($point, 'w')) then 
     41                        element {name($e)} {concat('-', $value)}  
     42                else $e 
     43        else  $e 
     44} ; 
    2145 
    2246for $DIF in collection($input_collection)/dif:DIF[dif:Entry_ID=$input_entry_id] 
     
    7599                                                                } 
    76100                                                }, 
    77                                                 element ParameterName {'dummy term'}, 
    78                                                 element ParameterAbbreviation {'dummy term'} 
     101                                                element ParameterName { 
     102                                                        concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)), 
     103                                                        if (exists($parameter/dif:Variable)) then 
     104                                                                concat(' > ', string($parameter/dif:Variable)) 
     105                                                        else (), 
     106                                                        if (exists($parameter/dif:Detailed_Variable)) then 
     107                                                                concat(' > ', string($parameter/dif:Detailed_Variable)) 
     108                                                        else () 
     109                                                }, 
     110                                                element ParameterAbbreviation { 
     111                                                        concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)), 
     112                                                        if (exists($parameter/dif:Variable)) then 
     113                                                                concat(' > ', string($parameter/dif:Variable)) 
     114                                                        else (), 
     115                                                        if (exists($parameter/dif:Detailed_Variable)) then 
     116                                                                concat(' > ', string($parameter/dif:Detailed_Variable)) 
     117                                                        else () 
     118                                                } 
    79119                                        }, 
    80                                 if (exists($DIF/dif:Spatial_Coverage) or exists($DIF/dif:Location) or exists($DIF/dif:Temporal_Coverage)) then 
     120                                if (exists($DIF/dif:Spatial_Coverage) or exists($DIF/dif:Paleo_Temporal_Coverage) or exists($DIF/dif:Location) or exists($DIF/dif:Temporal_Coverage)) then 
    81121                                        element dgDataCoverage { 
    82                                                 if (exists($DIF/dif:Spatial_Coverage/dif:Northernmost_Latitude) or exists($DIF/(dif:Location)))  then 
     122                                                if (exists($DIF/dif:Spatial_Coverage)  or exists($DIF/dif:Location))  then 
    83123                                                        element dgSpatialCoverage { 
    84                                                                 for $boundingbox in $DIF/dif:Spatial_Coverage[exists(dif:Northernmost_Latitude)] 
     124                                                                for $boundingbox in $DIF/dif:Spatial_Coverage[exists(dif:Northernmost_Latitude) 
     125                                                                                                                and exists(dif:Southernmost_Latitude) 
     126                                                                                                                and exists(dif:Easternmost_Longitude) 
     127                                                                                                                and exists(dif:Westernmost_Longitude)] 
    85128                                                                return 
    86129                                                                        element BoundingBox { 
    87                                                                                 element LimitNorth {string($boundingbox/dif:Northernmost_Latitude)}, 
    88                                                                                 element LimitSouth {string($boundingbox/dif:Southernmost_Latitude)}, 
    89                                                                                 element LimitWest {string($boundingbox/dif:Westernmost_Longitude)}, 
    90                                                                                 element LimitEast {string($boundingbox/dif:Easternmost_Longitude)} 
     130                                                                                element LimitNorth {data(f:fix-coord($boundingbox/dif:Northernmost_Latitude))}, 
     131                                                                                element LimitSouth {data(f:fix-coord($boundingbox/dif:Southernmost_Latitude))}, 
     132                                                                                element LimitWest {data(f:fix-coord($boundingbox/dif:Westernmost_Longitude))}, 
     133                                                                                element LimitEast {data(f:fix-coord($boundingbox/dif:Easternmost_Longitude))} 
    91134                                                                        }, 
    92135                                                                for $location in $DIF/dif:Location 
     
    101144                                                        } 
    102145                                                else (), 
    103                                                 if (exists($DIF/dif:Temporal_Coverage/dif:Start_Date)) then 
     146                                                if (exists($DIF/dif:Temporal_Coverage/dif:Start_Date) or exists($DIF/dif:Paleo_Temporal_Coverage/dif:Paleo_Start_Date) or exists($DIF/dif:Chronostratigraphic_Unit)) then 
    104147                                                        element dgTemporalCoverage { 
    105                                                                 for $temporalcoverage in $DIF/dif:Temporal_Coverage[exists(dif:Start_Date) and exists(dif:Stop_Date)] 
     148                                                                for $temporalcoverage in $DIF/dif:Temporal_Coverage[exists(dif:Start_Date)] 
    106149                                                                return 
    107150                                                                        element DateRange { 
    108151                                                                                element DateRangeStart {string($temporalcoverage/dif:Start_Date)}, 
    109152                                                                                element DateRangeEnd {string($temporalcoverage/dif:Stop_Date)} 
     153                                                                        }, 
     154                                                                for $paleotemporalcoverage in $DIF/dif:Paleo_Temporal_Coverage[exists(dif:Paleo_Start_Date)] 
     155                                                                return 
     156                                                                        element DateRange { 
     157                                                                                element DateRangeStart {string($paleotemporalcoverage/dif:Paleo_Start_Date)}, 
     158                                                                                element DateRangeEnd {string($paleotemporalcoverage/dif:Paleo_Stop_Date)} 
     159                                                                        }, 
     160                                                                for $chronostratigraphic in $DIF/dif:Chronostratigraphic_Unit 
     161                                                                return 
     162                                                                        element dgChronostratigraphicTerm { 
     163                                                                                element dgValidTerm {string($chronostratigraphic)}, 
     164                                                                                element dgValidTermID { 
     165                                                                                        element ParentListID {$gcmd_paleotemporal_valids}, 
     166                                                                                        element TermID {escape-uri($chronostratigraphic, true())} 
     167                                                                                } 
    110168                                                                        } 
    111169                                                        } 
     
    115173                        }, 
    116174                        element dgDataRoles { 
    117                                 if (exists($DIF/(dif:Data_Set_Citation/dif:Dataset_Creator | dif:Originating_Center))) then 
     175                                if (exists($DIF/dif:Data_Set_Citation/dif:Dataset_Creator)) then 
    118176                                        element dgDataCreator { 
    119177                                                element dgMetadataID { 
     
    124182                                                element roleName {'Data Creator'}, 
    125183                                                element abbreviation {'Creator'}, 
    126                                                 for $creatorID in $DIF/(dif:Data_Set_Citation/dif:Dataset_Creator | dif:Originating_Center) 
     184                                                for $creatorID in $DIF/dif:Data_Set_Citation/dif:Dataset_Creator 
     185                                                return 
     186                                                element dgRoleHolder { 
     187                                                        element dgOrganisationID { 
     188                                                                element schemeIdentifier {'NDG-B0'}, 
     189                                                                element repositoryIdentifier {$input_repository}, 
     190                                                                element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID)), true())} 
     191                                                        }, 
     192                                                element startDate {current-date()} 
     193                                                } 
     194                                        } 
     195                                else if (exists($DIF/dif:Originating_Center)) then 
     196                                        element dgDataCreator { 
     197                                                element dgMetadataID { 
     198                                                        element schemeIdentifier {'NDG-B0'}, 
     199                                                        element repositoryIdentifier {$input_repository}, 
     200                                                        element localIdentifier {concat('generated_creator-', string($DIF/dif:Entry_ID))} 
     201                                                }, 
     202                                                element roleName {'Data Creator'}, 
     203                                                element abbreviation {'Creator'}, 
     204                                                for $creatorID in $DIF/dif:Originating_Center 
    127205                                                return 
    128206                                                element dgRoleHolder { 
     
    156234                }, 
    157235                element dgStructuredKeyword { 
    158                         element dgValidTerm {'MDIP'}, 
     236                        element dgValidTerm {'d2b converted record'}, 
    159237                        element dgValidTermID { 
    160                                 element ParentListID {$ndg_data_provider_vocab}, 
    161                                 element TermID {'NDGO0001'} 
     238                                element ParentListID {$unknown_vocab_id}, 
     239                                element TermID {'d2b'} 
    162240                        } 
    163241                }, 
  • TI07-MOLES/trunk/JavaCode/BuildMOLES/ndg/services/buildmoles/Main.java

    r1827 r1832  
    325325                                                localID = DEListInstanceXML.getDocumentElement().getElementsByTagName("repositoryID").item(0).getFirstChild().getNodeValue(); 
    326326 
    327                                                 xquery = "declare default element namespace 'http://ndg.nerc.ac.uk/moles';declare namespace dif='http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/';declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions';declare variable $input_collection as xs:string {'TargetCollection'};declare variable $unknown_vocab_id as xs:string {'http://vocab.ndg.nerc.ac.uk/null'};declare variable $ndg_data_provider_vocab as xs:string {'http://vocab.ndg.nerc.ac.uk/N010'};declare variable $gcmd_science_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'};declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'};declare variable $gcmd_location_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/locations.html'};declare variable $gcmd_iso_topic_list as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/iso_topic_list.html'};declare variable $cf_standard_names as xs:string {'http://www.cgd.ucar.edu/cms/eaton/cf-metadata/standard_name.html'};declare variable $iso_topic_list as xs:string {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'};declare variable $input_repository as xs:string {'Input_Repository_Code'};declare variable $input_repository_local as xs:string {'Input_Repository_LocalID'};declare variable $input_entry_id as xs:string {'Input_Entry_ID'};for $DIF in collection($input_collection)/dif:DIF[dif:Entry_ID=$input_entry_id] return element dgMetadata {element dgMetadataRecord {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {string($DIF/dif:Entry_ID)}},element dgMetadataDescription {element metadataDescriptionID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {concat('generated_desc-', string($DIF/dif:Entry_ID))}},element metadataDescriptionLastUpdated {current-date()},element abstract {element abstractText {string($DIF/dif:Summary)}}},element name {string($DIF/dif:Entry_Title)},element abbreviation {string($DIF/dif:Entry_Title)},element dgDataEntity {element dgDataSetType {''},element dgDataSummary { for $parameter in $DIF/dif:Parameters return element dgParameterSummary {element dgParameterValue {element dgValueDataParameter {element Value {''},element dgStandardUnit {element dgValidTerm {'dummy'},element dgValidTermID {element ParentListID {$unknown_vocab_id},element TermID {escape-uri('dummy unit', true())}}}}},element dgStdParameterMeasured {element dgValidTerm {concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)),if (exists($parameter/dif:Variable)) then concat(' > ', string($parameter/dif:Variable)) else (),if (exists($parameter/dif:Detailed_Variable)) then concat(' > ', string($parameter/dif:Detailed_Variable)) else ()},element dgValidTermID {element ParentListID {$gcmd_science_valids},element TermID {escape-uri($parameter/dif:Category, true())}}},element ParameterName {concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)),if (exists($parameter/dif:Variable)) then concat(' > ', string($parameter/dif:Variable)) else (),if (exists($parameter/dif:Detailed_Variable)) then concat(' > ', string($parameter/dif:Detailed_Variable)) else ()},element ParameterAbbreviation {concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)),if (exists($parameter/dif:Variable)) then concat(' > ', string($parameter/dif:Variable)) else (),if (exists($parameter/dif:Detailed_Variable)) then concat(' > ', string($parameter/dif:Detailed_Variable)) else ()}},if (exists($DIF/dif:Spatial_Coverage) or exists($DIF/dif:Location) or exists($DIF/dif:Temporal_Coverage)) then element dgDataCoverage {if (exists($DIF/dif:Spatial_Coverage/dif:Northernmost_Latitude) or exists($DIF/(dif:Location)))  then element dgSpatialCoverage {for $boundingbox in $DIF/dif:Spatial_Coverage[exists(dif:Northernmost_Latitude)] return element BoundingBox {element LimitNorth {string($boundingbox/dif:Northernmost_Latitude)},element LimitSouth {string($boundingbox/dif:Southernmost_Latitude)},element LimitWest {string($boundingbox/dif:Westernmost_Longitude)},element LimitEast {string($boundingbox/dif:Easternmost_Longitude)}},for $location in $DIF/dif:Location return element dgArea {element dgValidTerm {string($location)},element dgValidTermID {element ParentListID {$gcmd_location_valids},element TermID {escape-uri($location, true())}}}} else (),if (exists($DIF/dif:Temporal_Coverage/dif:Start_Date)) then element dgTemporalCoverage {for $temporalcoverage in $DIF/dif:Temporal_Coverage[exists(dif:Start_Date) and exists(dif:Stop_Date)] return element DateRange {element DateRangeStart {string($temporalcoverage/dif:Start_Date)},element DateRangeEnd {string($temporalcoverage/dif:Stop_Date)}}} else ()} else ()},element dgDataRoles {if (exists($DIF/(dif:Data_Set_Citation/dif:Dataset_Creator | dif:Originating_Center))) then element dgDataCreator {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {concat('generated_creator-', string($DIF/dif:Entry_ID))}},element roleName {'Data Creator'},element abbreviation {'Creator'},for $creatorID in $DIF/(dif:Data_Set_Citation/dif:Dataset_Creator | dif:Originating_Center) return element dgRoleHolder {element dgOrganisationID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID)), true())}},element startDate {current-date()}}} else (),element dgDataCurator {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {concat('generated_curator-', string($DIF/dif:Entry_ID))}},element roleName {'Data Curator'},element abbreviation {'Curator'},element dgRoleHolder {element dgOrganisationID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {$input_repository_local}},element startDate {current-date()}}}}},element dgStructuredKeyword {element dgValidTerm {'MDIP'},element dgValidTermID {element ParentListID {$ndg_data_provider_vocab},element TermID {'NDGO0001'}}},for $structuredKeywords in $DIF/dif:Keywords return  element dgStructuredKeyword {element dgValidTerm {$structuredKeywords},element dgValidTermID {element ParentListID {$unknown_vocab_id},element TermID {escape-uri($structuredKeywords, true())}}},for $structuredKeywords in $DIF/dif:ISO_Topic_Category return  element dgStructuredKeyword {element dgValidTerm {string($structuredKeywords)},element dgValidTermID {element ParentListID {$gcmd_iso_topic_list},element TermID {escape-uri($structuredKeywords, true())}}},if (exists($DIF/dif:DIF_Creation_Date) or exists($DIF/dif:Last_DIF_Revision_Date)) then  element dgMetadataProvenance {if (exists($DIF/dif:DIF_Creation_Date)) then element RecordCreation {element CreatedDate {if (string($DIF/dif:DIF_Creation_Date) castable as xs:date) then  string($DIF/dif:DIF_Creation_Date) cast as xs:date else (current-date())},element CreatedBy {$input_repository}} else  element RecordCreation {element CreatedDate {current-date()},element CreatedBy {'MOLES Import'}},if (exists($DIF/dif:Last_DIF_Revision_Date)) then element RecordUpdate {element UpdateDate {if (string($DIF/dif:Last_DIF_Revision_Date) castable as xs:dateTime) then  string($DIF/dif:Last_DIF_Revision_Date) cast as xs:dateTime else (current-dateTime())},element UpdatedBy {$input_repository}} else ()} else ()},for $creator in distinct-values($DIF/(dif:Data_Set_Citation/dif:Dataset_Creator | dif:Originating_Center)) return element dgOrganisation {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {escape-uri(concat('generated_orgcit-', string($creator)), true())}},element name {string($creator)},element abbreviation {string($creator)},element contactDetails {''}}}"; 
     327                                                xquery = "declare default element namespace 'http://ndg.nerc.ac.uk/moles';declare namespace dif='http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/';declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions';declare variable $input_collection as xs:string {'TargetCollection'};declare variable $unknown_vocab_id as xs:string {'http://vocab.ndg.nerc.ac.uk/null'};declare variable $ndg_data_provider_vocab as xs:string {'http://vocab.ndg.nerc.ac.uk/N010'};declare variable $gcmd_science_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'};declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'};declare variable $gcmd_location_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/locations.html'};declare variable $gcmd_paleotemporal_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/paleotemporal.html'};declare variable $gcmd_iso_topic_list as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/iso_topic_list.html'};declare variable $cf_standard_names as xs:string {'http://www.cgd.ucar.edu/cms/eaton/cf-metadata/standard_name.html'};declare variable $iso_topic_list as xs:string {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'};declare variable $input_repository as xs:string {'Input_Repository_Code'};declare variable $input_repository_local as xs:string {'Input_Repository_LocalID'};declare variable $input_entry_id as xs:string {'Input_Entry_ID'};declare function f:fix-coord($e as element()) as element() {if ($e castable as xs:decimal) then  $e else let $value := substring(data($e), 1, string-length($e)-1) let $point := lower-case(data($e)) return if ($value  castable as xs:decimal) then   if (ends-with($point, 'n')) then element {name($e)} {$value}  else if (ends-with($point, 's')) then element {name($e)} {concat('-', $value)}  else if (ends-with($point, 'e')) then element {name($e)} {$value}  else if (ends-with($point, 'w')) then element {name($e)} {concat('-', $value)}  else $e else  $e};for $DIF in collection($input_collection)/dif:DIF[dif:Entry_ID=$input_entry_id] return element dgMetadata {element dgMetadataRecord {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {string($DIF/dif:Entry_ID)}},element dgMetadataDescription {element metadataDescriptionID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {concat('generated_desc-', string($DIF/dif:Entry_ID))}},element metadataDescriptionLastUpdated {current-date()},element abstract {element abstractText {string($DIF/dif:Summary)}}},element name {string($DIF/dif:Entry_Title)},element abbreviation {string($DIF/dif:Entry_Title)},element dgDataEntity {element dgDataSetType {''},element dgDataSummary {for $parameter in $DIF/dif:Parameters return element dgParameterSummary {element dgParameterValue {element dgValueDataParameter {element Value {''},element dgStandardUnit {element dgValidTerm {'dummy'},element dgValidTermID {element ParentListID {$unknown_vocab_id},element TermID {escape-uri('dummy unit', true())}}}}},element dgStdParameterMeasured {element dgValidTerm {concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)),if (exists($parameter/dif:Variable)) then concat(' > ', string($parameter/dif:Variable)) else (),if (exists($parameter/dif:Detailed_Variable)) then concat(' > ', string($parameter/dif:Detailed_Variable)) else ()},element dgValidTermID {element ParentListID {$gcmd_science_valids},element TermID {escape-uri($parameter/dif:Category, true())}}},element ParameterName {concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)),if (exists($parameter/dif:Variable)) then concat(' > ', string($parameter/dif:Variable)) else (),if (exists($parameter/dif:Detailed_Variable)) then concat(' > ', string($parameter/dif:Detailed_Variable)) else ()},element ParameterAbbreviation {concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)),if (exists($parameter/dif:Variable)) then concat(' > ', string($parameter/dif:Variable)) else (),if (exists($parameter/dif:Detailed_Variable)) then concat(' > ', string($parameter/dif:Detailed_Variable)) else ()}},if (exists($DIF/dif:Spatial_Coverage) or exists($DIF/dif:Paleo_Temporal_Coverage) or exists($DIF/dif:Location) or exists($DIF/dif:Temporal_Coverage)) then element dgDataCoverage {if (exists($DIF/dif:Spatial_Coverage)  or exists($DIF/dif:Location))  then element dgSpatialCoverage {for $boundingbox in $DIF/dif:Spatial_Coverage[exists(dif:Northernmost_Latitude) and exists(dif:Southernmost_Latitude) and exists(dif:Easternmost_Longitude) and exists(dif:Westernmost_Longitude)] return element BoundingBox {element LimitNorth {data(f:fix-coord($boundingbox/dif:Northernmost_Latitude))},element LimitSouth {data(f:fix-coord($boundingbox/dif:Southernmost_Latitude))},element LimitWest {data(f:fix-coord($boundingbox/dif:Westernmost_Longitude))},element LimitEast {data(f:fix-coord($boundingbox/dif:Easternmost_Longitude))}},for $location in $DIF/dif:Location return element dgArea {element dgValidTerm {string($location)},element dgValidTermID {element ParentListID {$gcmd_location_valids},element TermID {escape-uri($location, true())}}}} else (),if (exists($DIF/dif:Temporal_Coverage/dif:Start_Date) or exists($DIF/dif:Paleo_Temporal_Coverage/dif:Paleo_Start_Date) or exists($DIF/dif:Chronostratigraphic_Unit)) then element dgTemporalCoverage {for $temporalcoverage in $DIF/dif:Temporal_Coverage[exists(dif:Start_Date)] return element DateRange {element DateRangeStart {string($temporalcoverage/dif:Start_Date)},element DateRangeEnd {string($temporalcoverage/dif:Stop_Date)}},for $paleotemporalcoverage in $DIF/dif:Paleo_Temporal_Coverage[exists(dif:Paleo_Start_Date)] return element DateRange {element DateRangeStart {string($paleotemporalcoverage/dif:Paleo_Start_Date)},element DateRangeEnd {string($paleotemporalcoverage/dif:Paleo_Stop_Date)}},for $chronostratigraphic in $DIF/dif:Chronostratigraphic_Unit return element dgChronostratigraphicTerm {element dgValidTerm {string($chronostratigraphic)},element dgValidTermID {element ParentListID {$gcmd_paleotemporal_valids},element TermID {escape-uri($chronostratigraphic, true())}}}} else ()} else ()},element dgDataRoles {if (exists($DIF/dif:Data_Set_Citation/dif:Dataset_Creator)) then element dgDataCreator {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {concat('generated_creator-', string($DIF/dif:Entry_ID))}},element roleName {'Data Creator'},element abbreviation {'Creator'},for $creatorID in $DIF/dif:Data_Set_Citation/dif:Dataset_Creator return element dgRoleHolder {element dgOrganisationID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID)), true())}},element startDate {current-date()}}} else if (exists($DIF/dif:Originating_Center)) then element dgDataCreator {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {concat('generated_creator-', string($DIF/dif:Entry_ID))}},element roleName {'Data Creator'},element abbreviation {'Creator'},for $creatorID in $DIF/dif:Originating_Center return element dgRoleHolder {element dgOrganisationID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID)), true())}},element startDate {current-date()}}} else (),element dgDataCurator {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {concat('generated_curator-', string($DIF/dif:Entry_ID))}},element roleName {'Data Curator'},element abbreviation {'Curator'},element dgRoleHolder {element dgOrganisationID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {$input_repository_local}},element startDate {current-date()}}}}},element dgStructuredKeyword {element dgValidTerm {'d2b converted record'},element dgValidTermID {element ParentListID {$unknown_vocab_id},element TermID {'d2b'}}},for $structuredKeywords in $DIF/dif:Keywords return  element dgStructuredKeyword {element dgValidTerm {$structuredKeywords},element dgValidTermID {element ParentListID {$unknown_vocab_id},element TermID {escape-uri($structuredKeywords, true())}}},for $structuredKeywords in $DIF/dif:ISO_Topic_Category return  element dgStructuredKeyword {element dgValidTerm {string($structuredKeywords)},element dgValidTermID {element ParentListID {$gcmd_iso_topic_list},element TermID {escape-uri($structuredKeywords, true())}}},if (exists($DIF/dif:DIF_Creation_Date) or exists($DIF/dif:Last_DIF_Revision_Date)) then  element dgMetadataProvenance {if (exists($DIF/dif:DIF_Creation_Date)) then element RecordCreation {element CreatedDate {if (string($DIF/dif:DIF_Creation_Date) castable as xs:date) then  string($DIF/dif:DIF_Creation_Date) cast as xs:date else (current-date())},element CreatedBy {$input_repository}} else  element RecordCreation {element CreatedDate {current-date()},element CreatedBy {'MOLES Import'}},if (exists($DIF/dif:Last_DIF_Revision_Date)) then element RecordUpdate {element UpdateDate {if (string($DIF/dif:Last_DIF_Revision_Date) castable as xs:dateTime) then  string($DIF/dif:Last_DIF_Revision_Date) cast as xs:dateTime else (current-dateTime())},element UpdatedBy {$input_repository}} else ()} else ()},for $creator in distinct-values($DIF/(dif:Data_Set_Citation/dif:Dataset_Creator | dif:Originating_Center)) return element dgOrganisation {element dgMetadataID {element schemeIdentifier {'NDG-B0'},element repositoryIdentifier {$input_repository},element localIdentifier {escape-uri(concat('generated_orgcit-', string($creator)), true())}},element name {string($creator)},element abbreviation {string($creator)},element contactDetails {''}}}"; 
    328328                                                xquery = xquery.replaceFirst("Input_Repository_Code", repositoryID); 
    329329                                                xquery = xquery.replaceFirst("Input_Repository_LocalID", repositoryLocalID); 
Note: See TracChangeset for help on using the changeset viewer.