Changeset 3149


Ignore:
Timestamp:
14/12/07 15:15:21 (10 years ago)
Author:
mpritcha
Message:

quick fix to DPPP problem. Better solution reading xqueries from external file to follow.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/JavaCode/BuildMOLE/ndg/services/buildmole/Main.java

    r2370 r3149  
    183183                } 
    184184        else if (inputType.equals("DIF")) { 
    185                 xquery = "import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; import module namespace inputParse='http://ndg.nerc.ac.uk/xquery/lib/inputParse' at 'xmldb:exist:///db/xqueryLib/Utilities/inputParse_xquery_lib.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 variable $targetCollection as xs:string {'TargetCollection'}; 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 variable $output_local_id as xs:string {'Output_LocalID'}; for $DIF in collection($targetCollection)/dif:DIF[dif:Entry_ID=$input_entry_id] return element dgMetadata { element dgMetadataRecord { element dgMetadataID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier {$output_local_id} else element localIdentifier {data($DIF/dif:Entry_ID)}}, element dgMetadataDescription { element metadataDescriptionID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier {concat('generated_desc-', $output_local_id)} else element localIdentifier {concat('generated_desc-', escape-uri(string($DIF/dif:Entry_ID), true()))}}, element metadataDescriptionLastUpdated {current-date()}                   , element abstract { element abstractText {string($DIF/dif:Summary)}, for $descOnline in $DIF/dif:Related_URL return element descriptionSection { element descriptionOnlineReference { element dgSimpleLink {escape-uri(data($descOnline/dif:URL), true())}}, if (exists($descOnline/dif:URL_Content_Type)) then  element dgReferenceName {data($descOnline/dif:URL)} else ()}}}, 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 {$voclib:unknown_vocab_id}, element TermID {escape-uri('dummy unit', true())}}}}}, element dgStdParameterMeasured { if ($parameter/dif:Category!='') then element dgValidTerm {string($parameter/dif:Category)} else  element dgValidTerm {'unknown'}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_categories, '/current')}, element TermID {escape-uri($parameter/dif:Category, true())}}, element dgValidSubterm { if ($parameter/dif:Topic!='') then element dgValidTerm {string($parameter/dif:Topic)} else  element dgValidTerm {'unknown'}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_topics, '/current')}, element TermID {escape-uri($parameter/dif:Topic, true())}}, element dgValidSubterm { if ($parameter/dif:Term!='') then element dgValidTerm {string($parameter/dif:Term)} else  element dgValidTerm {'unknown'}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_terms, '/current')}, element TermID {escape-uri($parameter/dif:Term, true())}}, if (exists($parameter/dif:Variable) and $parameter/dif:Variable!='') then element dgValidSubterm { element dgValidTerm {string($parameter/dif:Variable)}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_variables, '/current')}, element TermID {escape-uri($parameter/dif:Variable, true())}}, if (exists($parameter/dif:Detailed_Variable) and $parameter/dif:Detailed_Variable!='') then element dgValidSubterm { element dgValidTerm {string($parameter/dif:Detailed_Variable)}, element dgValidTermID { element ParentListID {$voclib:unknown_vocab_id}, element TermID {escape-uri($parameter/dif:Detailed_Variable, true())}}, element ListLevel {4}} else (), element ListLevel {3}} else (), element ListLevel {2}}, element ListLevel {1}}, element ListLevel {0}}, element ParameterName { concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)), if (exists($parameter/dif:Variable) and $parameter/dif:Variable!='') then concat(' > ', string($parameter/dif:Variable)) else (), if (exists($parameter/dif:Detailed_Variable) and $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) and $parameter/dif:Variable!='') then concat(' > ', string($parameter/dif:Variable)) else (), if (exists($parameter/dif:Detailed_Variable) and $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(inputParse:fix-coord($boundingbox/dif:Northernmost_Latitude))}, element LimitSouth {data(inputParse:fix-coord($boundingbox/dif:Southernmost_Latitude))}, element LimitWest {data(inputParse:fix-coord($boundingbox/dif:Westernmost_Longitude))}, element LimitEast {data(inputParse:fix-coord($boundingbox/dif:Easternmost_Longitude))}}, for $location in $DIF/dif:Location return element dgArea { element dgValidTerm {string($location)}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_location_valids, '/current')}, element TermID {escape-uri($location, true())}}}} else (), if (exists($DIF/dif:Temporal_Coverage) or exists($DIF/dif:Paleo_Temporal_Coverage) 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 {concat($voclib:gcmd_chronostratigraphic_valids, '/current')}, 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier {concat('generated_creator-', $output_local_id)} else element localIdentifier {concat('generated_creator-', escape-uri(string($DIF/dif:Entry_ID), true()))}}, element roleName {'Data Creator'}, element abbreviation {'Creator'}, for $creatorID in $DIF/dif:Data_Set_Citation/dif:Dataset_Creator return element dgRoleHolder { element dgMetadataID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)), 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_creator-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_creator-', data($DIF/dif:Entry_ID)), true())}}, 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)), true())}}, element startDate {current-date()}}} else (), element dgDataCurator { element dgMetadataID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_curator-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_curator-', data($DIF/dif:Entry_ID)), true())}}, 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 {$voclib:unknown_vocab_id}, element TermID {'d2b'}}}, for $structuredKeywords in $DIF/dif:Keyword return  element dgStructuredKeyword { element dgValidTerm {string($structuredKeywords)}, element dgValidTermID { if ($structuredKeywords='MDIP' or $structuredKeywords='NERC' or $structuredKeywords='NERC_DDC') then element ParentListID {concat($voclib:ndg_data_provider_vocab, '/current')} else element ParentListID {$voclib: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 {concat($voclib:iso_topic_list, '/current')}, 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 ()} (: </dgMetadataRecord>:), 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creator), '-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creator), '-', data($DIF/dif:Entry_ID)), true())}}, element name {string($creator)}, element abbreviation {string($creator)}, element contactDetails {''}}}"; 
     185                xquery = "import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; import module namespace inputParse='http://ndg.nerc.ac.uk/xquery/lib/inputParse' at 'xmldb:exist:///db/xqueryLib/Utilities/inputParse_xquery_lib.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 variable $targetCollection as xs:string {'TargetCollection'}; 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 variable $output_local_id as xs:string {'Output_LocalID'}; for $DIF in collection($targetCollection)/dif:DIF[dif:Entry_ID=$input_entry_id] return element dgMetadata { element dgMetadataRecord { element dgMetadataID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier {$output_local_id} else element localIdentifier {data($DIF/dif:Entry_ID)}}, element dgMetadataDescription { element metadataDescriptionID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier {concat('generated_desc-', $output_local_id)} else element localIdentifier {concat('generated_desc-', escape-uri(string($DIF/dif:Entry_ID), true()))}}, element metadataDescriptionLastUpdated {current-date()}                   , element abstract { element abstractText {string($DIF/dif:Summary)}, for $descOnline in $DIF/dif:Related_URL return element descriptionSection { element descriptionOnlineReference { element dgSimpleLink {escape-uri(data($descOnline/dif:URL), true())}}, if (exists($descOnline/dif:URL_Content_Type)) then  element dgReferenceName {data($descOnline/dif:URL)} else ()}}}, 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 {$voclib:unknown_vocab_id}, element TermID {escape-uri('dummy unit', true())}}}}}, element dgStdParameterMeasured { if ($parameter/dif:Category!='') then element dgValidTerm {string($parameter/dif:Category)} else  element dgValidTerm {'unknown'}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_categories, '/current')}, element TermID {escape-uri($parameter/dif:Category, true())}}, element dgValidSubterm { if ($parameter/dif:Topic!='') then element dgValidTerm {string($parameter/dif:Topic)} else  element dgValidTerm {'unknown'}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_topics, '/current')}, element TermID {escape-uri($parameter/dif:Topic, true())}}, element dgValidSubterm { if ($parameter/dif:Term!='') then element dgValidTerm {string($parameter/dif:Term)} else  element dgValidTerm {'unknown'}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_terms, '/current')}, element TermID {escape-uri($parameter/dif:Term, true())}}, if (exists($parameter/dif:Variable) and $parameter/dif:Variable!='') then element dgValidSubterm { element dgValidTerm {string($parameter/dif:Variable)}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_science_valids_variables, '/current')}, element TermID {escape-uri($parameter/dif:Variable, true())}}, if (exists($parameter/dif:Detailed_Variable) and $parameter/dif:Detailed_Variable!='') then element dgValidSubterm { element dgValidTerm {string($parameter/dif:Detailed_Variable)}, element dgValidTermID { element ParentListID {$voclib:unknown_vocab_id}, element TermID {escape-uri($parameter/dif:Detailed_Variable, true())}}, element ListLevel {4}} else (), element ListLevel {3}} else (), element ListLevel {2}}, element ListLevel {1}}, element ListLevel {0}}, element ParameterName { concat (string($parameter/dif:Category), ' > ', string($parameter/dif:Topic), ' > ', string($parameter/dif:Term)), if (exists($parameter/dif:Variable) and $parameter/dif:Variable!='') then concat(' > ', string($parameter/dif:Variable)) else (), if (exists($parameter/dif:Detailed_Variable) and $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) and $parameter/dif:Variable!='') then concat(' > ', string($parameter/dif:Variable)) else (), if (exists($parameter/dif:Detailed_Variable) and $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(inputParse:fix-coord($boundingbox/dif:Northernmost_Latitude))}, element LimitSouth {data(inputParse:fix-coord($boundingbox/dif:Southernmost_Latitude))}, element LimitWest {data(inputParse:fix-coord($boundingbox/dif:Westernmost_Longitude))}, element LimitEast {data(inputParse:fix-coord($boundingbox/dif:Easternmost_Longitude))}}, for $location in $DIF/dif:Location return element dgArea { element dgValidTerm {string($location)}, element dgValidTermID { element ParentListID {concat($voclib:gcmd_location_valids, '/current')}, element TermID {escape-uri($location, true())}}}} else (), if (exists($DIF/dif:Temporal_Coverage) or exists($DIF/dif:Paleo_Temporal_Coverage) 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 {concat($voclib:gcmd_chronostratigraphic_valids, '/current')}, 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier {concat('generated_creator-', $output_local_id)} else element localIdentifier {concat('generated_creator-', escape-uri(string($DIF/dif:Entry_ID), true()))}}, element roleName {'Data Creator'}, element abbreviation {'Creator'}, for $creatorID in $DIF/dif:Data_Set_Citation/dif:Dataset_Creator return element dgRoleHolder { element dgMetadataID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)), 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_creator-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_creator-', data($DIF/dif:Entry_ID)), true())}}, 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)), true())}}, element startDate {current-date()}}} else (), element dgDataCurator { element dgMetadataID { element schemeIdentifier {'NDG-B0'}, element repositoryIdentifier {$input_repository}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_curator-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_curator-', data($DIF/dif:Entry_ID)), true())}}, 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 {$voclib:unknown_vocab_id}, element TermID {'d2b'}}}, for $structuredKeywords in $DIF/dif:Keyword return  element dgStructuredKeyword { element dgValidTerm {string($structuredKeywords)}, element dgValidTermID { if ($structuredKeywords='MDIP' or $structuredKeywords='NERC' or $structuredKeywords='NERC_DDC' or $structuredKeywords='DPPP') then element ParentListID {concat($voclib:ndg_data_provider_vocab, '/current')} else element ParentListID {$voclib: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 {concat($voclib:iso_topic_list, '/current')}, 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 ()} (: </dgMetadataRecord>:), 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}, if ($output_local_id != 'Output_LocalID') then element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creator), '-', $output_local_id), true())} else element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creator), '-', data($DIF/dif:Entry_ID)), true())}}, element name {string($creator)}, element abbreviation {string($creator)}, element contactDetails {''}}}"; 
    186186                xquery = xquery.replaceFirst("Input_Repository_Code", repositoryID); 
    187187                xquery = xquery.replaceFirst("Input_Repository_LocalID", repositoryLocalID); 
Note: See TracChangeset for help on using the changeset viewer.