Changeset 2008 for TI07-MOLES


Ignore:
Timestamp:
16/01/07 16:26:54 (12 years ago)
Author:
ko23
Message:

Updated XQueries (DIF/DC) B->D part 1

Location:
TI07-MOLES/trunk
Files:
9 edited

Legend:

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

    r1977 r2008  
    11(: Version for one DIF per dgMetadata instance :) 
    22(: Note algoritm for creating non-pre-existing organisations :) 
    3  (: dgPersons are not created as one can't tell automatically which are people and which are orgs, and orgs are simpler :)   
     3(: dgPersons are not created as one can't tell automatically which are people and which are orgs, and orgs are simpler :)   
    44 
    55declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
     
    77declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    88declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
     9 
    910declare variable $input_collection as xs:string {'TargetCollection'}; 
    1011 
     
    3031declare variable $input_repository_local as xs:string {'Input_Repository_LocalID'}; 
    3132declare variable $input_entry_id as xs:string {'Input_Entry_ID'}; 
     33declare variable $output_local_id as xs:string {'Output_LocalID'}; 
    3234 
    3335declare function f:fix-coord($e as element()) as element()  
     
    6163                        element schemeIdentifier {'NDG-B0'}, 
    6264                        element repositoryIdentifier {$input_repository}, 
    63                         element localIdentifier {string($DIF/dif:Entry_ID)} 
     65                        if ($output_local_id != 'Output_LocalID') then 
     66                                element localIdentifier {$output_local_id} 
     67                        else 
     68                                element localIdentifier {string($DIF/dif:Entry_ID)} 
    6469                }, 
    6570                element dgMetadataDescription { 
     
    188193                                                        element schemeIdentifier {'NDG-B0'}, 
    189194                                                        element repositoryIdentifier {$input_repository}, 
    190                                                         element localIdentifier {concat('generated_creator-', string($DIF/dif:Entry_ID))} 
     195                                                        element localIdentifier {concat('generated_creator-', string($DIF/dif:Entry_ID), '-', data($DIF/dif:Entry_ID))} 
    191196                                                }, 
    192197                                                element roleName {'Data Creator'}, 
     
    198203                                                                element schemeIdentifier {'NDG-B0'}, 
    199204                                                                element repositoryIdentifier {$input_repository}, 
    200                                                                 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID)), true())} 
     205                                                                element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)), true())} 
    201206                                                        }, 
    202207                                                element startDate {current-date()} 
     
    303308                                element schemeIdentifier {'NDG-B0'}, 
    304309                                element repositoryIdentifier {$input_repository}, 
    305                                 element localIdentifier {escape-uri(concat('generated_orgcit-', string($creator)), true())} 
     310                                element localIdentifier {escape-uri(concat('generated_orgcit-', string($creator), '-', data($DIF/dif:Entry_ID), '-', data($DIF/dif:Entry_ID)), true())} 
    306311                        }, 
    307312                        element name {string($creator)}, 
  • TI07-MOLES/trunk/DIF/XQuery/NDG-DIF.xquery

    r1744 r2008  
    197197                                    element Contact_Address { 
    198198                                        for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline 
    199                                             return element address {data($addressline)}, 
     199                                            return element Address {data($addressline)}, 
    200200                                                        if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then  
    201201                                        element City {string($DataCuratorRole/moles:contactDetails/moles:address/moles:city)} 
  • TI07-MOLES/trunk/DublinCore/XQuery/NDG-DublinCore.xquery

    r1886 r2008  
    33declare namespace dc='http://purl.org/dc/elements/1.1/'; 
    44declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc'; 
     5declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
    56declare variable $gcmd_science_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'}; 
    67declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'}; 
     
    89declare variable $iso_topic_list as xs:string {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'}; 
    910 
    10 for $DE in collection('/db/ndg_B_metadata')/dgMetadata/dgMetadataRecord[dgDataEntity!='' and dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='badc.nerc.ac.uk' and dgMetadataID/localIdentifier='dataent1'] 
     11for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[dgDataEntity!='' and dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='badc.nerc.ac.uk' and dgMetadataID/localIdentifier='dataent1'] 
    1112return  
    1213element oai_dc:dc { 
     
    1718        element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)}, 
    1819        element dc:date 
    19             { 
    20             if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then  
    21                 for $updatedate in $DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate 
    22                     order by xs:date($updatedate) descending 
    23                     return xs:date($updatedate[1]) 
    24             else  
    25                 string($DE/(dgMetadataProvenance | DataProvenance)/RecordCreation/CreatedDate)  
    26             }, 
    27          
     20                { 
     21                if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then 
     22                        for $updatedate in ($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate) 
     23                                order by xs:dateTime($updatedate) 
     24                        return data($updatedate[1]) 
     25                else 
     26                        string($DE/(dgMetadataProvenance | DataProvenance)/RecordCreation/CreatedDate)  
     27                }, 
    2828        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)  
    2929                order by $StructuredKeyword 
     
    3333        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)  
    3434                order by $StructuredKeyword1 
    35                 return  
     35        return  
    3636                element dc:subject  {string($StructuredKeyword1)}, 
    3737        for $DataCreatorRole in $DE/dgDataEntity/dgDataRoles/dgDataCreator/dgRoleHolder  
    38             order by $DataCreatorRole/startDate empty least 
    39                     return  
    40                 for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/dgMetadata/(dgOrganisation | dgPerson) 
    41                             [(dgMetadataID/schemeIdentifier='NDG-B0' 
    42                             and dgMetadataID/repositoryIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier 
    43                             and dgMetadataID/localIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] 
    44                 return  
    45                     element dc:creator { 
    46                     if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then 
    47                         (string($DataCreatorRoleHolder/name)) 
    48                     else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then 
    49                         (string(concat(string($DataCreatorRoleHolder/name/initials), ' ', string($DataCreatorRoleHolder/name/familyName)))) 
    50                     else ('empty content') 
    51                 }, 
    52             for $DataCuratorRole in $DE/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder[not(exists(endDate)) or endDate=''] 
    53             order by $DataCuratorRole/startDate empty least 
    54                 return  
    55                     for $DataCuratorRoleHolder in collection('/db/ndg_B_metadata')/dgMetadata/(dgOrganisation | dgPerson) 
    56                             [(dgMetadataID/schemeIdentifier='NDG-B0' 
    57                             and dgMetadataID/repositoryIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier 
    58                             and dgMetadataID/localIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] 
    59                         return  
    60                             element dc:publisher { 
    61                     if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then 
    62                         (string($DataCuratorRoleHolder/name)) 
    63                     else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then 
    64                         (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName)))) 
    65                     else ('empty content') 
    66                     } 
    67     }  (: </oai_dc:dc> :) 
     38                order by $DataCreatorRole/startDate empty least 
     39        return  
     40                for $DataCreatorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson) 
     41                        [(dgMetadataID/schemeIdentifier='NDG-B0' 
     42                        and dgMetadataID/repositoryIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier 
     43                        and dgMetadataID/localIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] 
     44                return  
     45                        element dc:creator { 
     46                                if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then 
     47                                        (string($DataCreatorRoleHolder/name)) 
     48                                else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then 
     49                                        (string(concat(string($DataCreatorRoleHolder/name/initials), ' ', string($DataCreatorRoleHolder/name/familyName)))) 
     50                                else ('empty content') 
     51                        }, 
     52        for $DataCuratorRole in $DE/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder[not(exists(endDate)) or endDate=''] 
     53                order by $DataCuratorRole/startDate empty least 
     54        return  
     55                for $DataCuratorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson) 
     56                        [(dgMetadataID/schemeIdentifier='NDG-B0' 
     57                        and dgMetadataID/repositoryIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier 
     58                        and dgMetadataID/localIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] 
     59                return  
     60                        element dc:publisher { 
     61                                if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then 
     62                                        (string($DataCuratorRoleHolder/name)) 
     63                                else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then 
     64                                        (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName)))) 
     65                                else ('empty content') 
     66                        } 
     67}  (: </oai_dc:dc> :) 
  • TI07-MOLES/trunk/MDIP/MDIPRelated.spp

    r1886 r2008  
    88        <Folder FolderName="DTD/Schemas" ExtStr="dtd;dcd;xdr;biz;xsd"> 
    99                <File FilePath=".\Schemae\MDIPMetaData_v0_5.xsd" HomeFolder="Yes"/> 
     10                <File FilePath=".\Schemae\MDIPMetaData_v1_0.xsd" HomeFolder="Yes"/> 
    1011                <File FilePath=".\..\v1Schema\Schemae\ndgmetadata1.3.xsd" HomeFolder="Yes"/> 
    1112        </Folder> 
  • TI07-MOLES/trunk/MDIP/MDIPRelated.xpr

    r1926 r2008  
    77    </meta> 
    88    <projectTree name="MDIPRelated.xpr"> 
     9        <folder path="file:/c:/test/mdip2moles/"/> 
    910        <file name="../DIF/XQuery/DIF2MOLES.xquery"/> 
    1011        <file name="Examples/Gemini_MDIP_v0.5.xml"/> 
     
    1213        <file name="Schemae/MDIPMetaData_v0_5.xsd"/> 
    1314        <file name="../DIF/XQuery/NDG-DIF.xquery"/> 
     15        <file name="../DublinCore/XQuery/NDG-DublinCore.xquery"/> 
     16        <file name="../ISO19115-19139/XQuery/NDG-ISO19115-139.xquery"/> 
    1417        <file name="XQueries/NDG-MDIP.xquery"/> 
    1518        <file name="../v1Schema/Schemae/ndgmetadata1.3.xsd"/> 
  • TI07-MOLES/trunk/MDIP/XQueries/MDIP2MOLES.xquery

    r1977 r2008  
    11(: Version for one MDIP per dgMetadata instance :) 
    22(: Note algoritm for creating non-pre-existing organisations :) 
    3  (: dgPersons are not created as one can't tell automatically which are people and which are orgs, and orgs are simpler :)   
     3(: dgPersons are not created as one can't tell automatically which are people and which are orgs, and orgs are simpler :)   
     4(: Not producing valid MOLES as still got to work out parameter vocabulary namespaces in the subject field :)   
    45 
    56declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
     
    1314declare variable $input_repository_local as xs:string {'Input_Repository_LocalID'}; 
    1415declare variable $input_DatasetIdentifier as xs:string {'Input_Entry_ID'}; 
     16declare variable $output_local_id as xs:string {'Output_LocalID'}; 
    1517 
    1618declare variable $unknown_vocab_id as xs:string {'http://vocab.ndg.nerc.ac.uk/null'}; 
     
    2123 
    2224(: declare variable $gcmd_science_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'}; :) 
    23 declare variable $gcmd_science_valids as xs:string {'http://vocab.ndg.nerc.ac.uk/041'}; 
     25declare variable $gcmd_science_valids as xs:string {'http://vocab.ndg.nerc.ac.uk/P041'}; 
    2426declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'}; 
    2527declare variable $gcmd_location_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/locations.html'}; 
     
    6769                        element schemeIdentifier {'NDG-B0'}, 
    6870                        element repositoryIdentifier {$input_repository}, 
    69                         element localIdentifier {string($MDIP/mdip:DatasetIdentifier)} 
     71                        if ($output_local_id != 'Output_LocalID') then 
     72                                element localIdentifier {$output_local_id} 
     73                        else 
     74                                element localIdentifier {escape-uri(data($MDIP/mdip:DatasetIdentifier), true())} 
    7075                }, 
    7176                element dgMetadataDescription { 
     
    101106                                                }, 
    102107                                                element dgStdParameterMeasured { 
    103                                                         element dgValidTerm {string($parameter/mdip:SubjectName)}, 
     108                                                element dgValidTerm {string($parameter/mdip:SubjectName)}, 
    104109                                                                element dgValidTermID { 
    105110                                                                        element ParentListID {string($parameter/mdip:SubjectVocab)}, 
     
    162167                                        } (: /dgDataCoverage :), 
    163168                                        if (exists($MDIP/mdip:DatasetRefDate)) then 
    164                                                 element dgDatasetProvenance {element dgDataPublicationData {data($MDIP/mdip:DatasetRefDate)}} 
     169                                                element dgDatasetProvenance {element dgDataPublicationDate {data($MDIP/mdip:DatasetRefDate)}} 
    165170                                        else () 
    166171                        } (: /dgDataSummary :), 
     
    181186                                                                element schemeIdentifier {'NDG-B0'}, 
    182187                                                                element repositoryIdentifier {$input_repository}, 
    183                                                                 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID)), true())} 
     188                                                                element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($MDIP/mdip:DatasetIdentifier)), true())} 
    184189                                                        }, 
    185190                                                element startDate {current-date()} 
     
    286291                                element schemeIdentifier {'NDG-B0'}, 
    287292                                element repositoryIdentifier {$input_repository}, 
    288                                 element localIdentifier {escape-uri(concat('generated_orgcit-', string($creator/mdip:OriginatorName)), true())} 
     293                                element localIdentifier {escape-uri(concat('generated_orgcit-', string($creator/mdip:OriginatorName), '-', data($MDIP/mdip:DatasetIdentifier)), true())} 
    289294                        }, 
    290295                        element name {data($creator/mdip:OriginatorName)}, 
  • TI07-MOLES/trunk/PythonCode/wsgi/ndg_xqueries.py

    r1991 r2008  
    11# This version using xqueries from rev 1914 of  
    22# TI07-MOLES/trunk/JavaCode/returnmolesxmldb/ndg/services/returnmoles/Main.java 
    3  
     3# Update DIF/DC queries  
    44listingQuery=''' 
    55declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $DE 
     
    2222MOLESQuery = '''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''' 
    2323 
    24 DublinCoreDEQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles'; declare namespace dc='http://purl.org/dc/elements/1.1/'; declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc'; 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 $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'}; for $DE in collection('/db/ndg_B_metadata')/dgMetadata/dgMetadataRecord[dgDataEntity!='' and dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID'] return <oai_dc:dc xmlns:oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'> { element dc:title {string($DE/name)}, element dc:type {'Dataset'}, element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, ':DC:', $DE/dgMetadataID/localIdentifier)}, element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)}, element dc:date { if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then for $updatedate in $DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate order by xs:dateTime($updatedate) descending return xs:dateTime($updatedate[1]) else string($DE/(dgMetadataProvenance | DataProvenance)/RecordCreation/CreatedDate) }, 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) order by $StructuredKeyword return element dc:subject {string($StructuredKeyword)}, 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) order by $StructuredKeyword1 return element dc:subject {string($StructuredKeyword1)}, for $DataCreatorRole in $DE/dgDataEntity/dgDataRoles/dgDataCreator/dgRoleHolder order by $DataCreatorRole/startDate empty least return for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/dgMetadata/(dgOrganisation | dgPerson) [(dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier and dgMetadataID/localIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] return element dc:creator { if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then (string($DataCreatorRoleHolder/name)) else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then (string(concat(string($DataCreatorRoleHolder/name/initials), ' ', string($DataCreatorRoleHolder/name/familyName)))) else ('empty content') }, for $DataCuratorRole in $DE/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder[not(exists(endDate)) or endDate=''] order by $DataCuratorRole/startDate empty least return for $DataCuratorRoleHolder in collection('/db/ndg_B_metadata')/dgMetadata/(dgOrganisation | dgPerson) [(dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier and dgMetadataID/localIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] return element dc:publisher { if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then (string($DataCuratorRoleHolder/name)) else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName)))) else ('empty content') } } </oai_dc:dc>''' 
    25  
    26 DIFQuery = '''declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/';declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';declare namespace moles='http://ndg.nerc.ac.uk/moles';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 DIF {attribute xsi:schemaLocation {'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.4.xsd'},element Entry_ID {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':DIF:', $DE/moles:dgMetadataID/moles:localIdentifier)},element Entry_Title {string($DE/moles:name)},element Data_Set_Citation {for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] return  for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] return  element Data_Creator {if (exists($DataCreatorRoleHolder/moles:name/moles:initials)) then  string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName))) else  string($DataCreatorRoleHolder/moles:abbreviation)},element Dataset_Title {string($DE/moles:name)}},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]) return if (exists($StructuredKeyword/*/moles:dgValidTerm)) then  element Parameters {element Category {string($StructuredKeyword/*/moles:dgValidTerm)},if (exists($StructuredKeyword//moles:dgValidSubterm)  and $StructuredKeyword//moles:dgValidSubterm != ''  and $StructuredKeyword//moles:dgValidSubterm != ' ') then  for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)] where exists($Subterm/moles:dgValidSubterm) order by $Subterm/moles:ListLevel return  if ($Subterm/moles:ListLevel=1) then element Topic {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  else if ($Subterm/moles:ListLevel=2) then element Term {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  else element GCMD_Science_Valid {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} else()} else(),for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[moles:dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) return  element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)},for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ moles:dgValidTermID/moles:ParentListID!='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'  and  moles:dgValidTermID/moles:ParentListID!='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'  ]/moles:dgValidTerm) return element Keyword {string($Keyword)},  for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID)  return  element Sensor_Name {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)) return element Short_Name {data($DepDPTAbbrev)},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)) return element Long_Name {data($DepDPTName)}},for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID) return  element Source_Name {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)) return element Short_Name {data($DepObsStnAbbrev)},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)) return element Long_Name {data($DepObsStnName)}},for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgDateRange) return  element Temporal_Coverage {element Start_Date {data($TemporalRange/moles:DateRangeStart)},element End_Date {data($TemporalRange/moles:DateRangeEnd)}},for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea/moles:dgValidTerm) return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}},  for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure) return element Data_Set_Progress {data($Data_Set_Progress)},for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox) return  element Spatial_Coverage {element Southernmost_Latitude {data($BoundingBox/moles:LimitSouth)},element Northernmost_Latitude {data($BoundingBox/moles:LimitNorth)},element Westernmost_Longitude {data($BoundingBox/moles:LimitWest)},element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)}},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']) return element Location {$Location},  for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID) return  element Project {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) return  element Short_Name {data($DepActAbbrev)},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) return  element Long_Name {data($DepActName)}},if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then  for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule return  element Access_Constraints {if (exists($DG/moles:dgGranuleSummary/moles:dgGranuleName)) then  concat('For data granule ', $DG/moles:dgGranuleSummary/moles:dgGranuleName, ': ') else (),if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyURL)) then concat('See access control policy at ', escape-uri($DG/moles:accessControlPolicy/moles:accessControlPolicyURL, true())) else if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyText)) then data($DG/moles:accessControlPolicy/moles:accessControlPolicyText) else  for $securityCondition in $DG/moles:accessControlPolicy/moles:dgSecurityCondition return if (exists($securityCondition/moles:conditionExplanationText)) then concat('Effect: ', data($securityCondition/moles:effect), ' - ', data($securityCondition/moles:conditionExplanationText)) else concat('Effect: ', data($securityCondition/moles:effect), 'needs ', data($securityCondition/moles:attauthRole), ' from ', data($securityCondition/moles:dgAttributeAuthority))} else (),if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder)) then for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder  order by $DataCreatorRole/moles:startDate empty least return  for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:repositoryIdentifier and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:localIdentifier)] return  element Originating_Center {if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then (string($DataCreatorRoleHolder/moles:name)) else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then (string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName)))) else ('empty content')} else (),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:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/*/moles:repositoryIdentifier and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/*/moles:localIdentifier)] return  element Data_Center {element Data_Center_Name {element Short_Name {if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) else  string($DataCuratorRoleHolder/moles:abbreviation)},element Long_Name {if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) else string($DataCuratorRoleHolder/moles:name)}},if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:URI)) then  element Data_Center_URL {data($DataCuratorRoleHolder/moles:contactDetails/moles:URI)} else (),for $DGID in $DE/moles:dgDataEntity/moles:dgDataGranule/moles:dataModelID return  element Data_Set_ID {concat($DGID/moles:repositoryIdentifier, ':', $DGID/moles:schemeIdentifier, ':', $DGID/moles:localIdentifier)},element Personnel {element Role {'Data Center Contact'},if (exists($DataCuratorRoleHolder/name/knownAs)) then  element First_Name {string($DataCuratorRoleHolder/moles:name/moles:knownAs)} else if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  element First_Name {string($DataCuratorRoleHolder/moles:name/moles:initials)} else (),element Last_Name {if (exists($DataCuratorRoleHolder/moles:name/moles:familyName)) then  string($DataCuratorRoleHolder/moles:name/moles:familyName) else string($DataCuratorRoleHolder/moles:name)},if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then  element Email {string($DataCuratorRole/moles:contactDetails/moles:eMail)} else  if (exists($DataCuratorRoleHolder/contactDetails/eMail)) then  (element Email {string($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}) else (),if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then  element Phone {string($DataCuratorRole/moles:contactDetails/moles:telephone)} else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then  element Phone {string($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)} else (),if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then  element Fax {string($DataCuratorRole/moles:contactDetails/moles:fax)} else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then  element Fax {string($DataCuratorRoleHolder/moles:contactDetails/moles:fax)} else (),if (exists($DataCuratorRole/moles:contactDetails/moles:address)) then  element Contact_Address {for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline return element address {data($addressline)},if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then  element City {string($DataCuratorRole/moles:contactDetails/moles:address/moles:city)} else (),if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)) then  element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)} else (),if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:country)) then  element Country {string($DataCuratorRole/moles:contactDetails/moles:address/moles:country)} else ()} else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address)) then  element Contact_Address {for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline return element address {data($addressline)},if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then  element City {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)} else (),if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then  element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:postcode)} else (),if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)) then  element Country {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)} else ()} else ()}},element Summary {string($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)},element Related_URL {element URL_Content_Type {'NDG_B_SERVICE'},element URL {data($DE/moles:dgMetadataID/moles:repositoryIdentifier)},element Description {'The NDG service for browsing metadata.'}},for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule return if ($DG/moles:dataModelID/moles:schemeIdentifier='NDG-A0') then  (element Related_URL {element URL_Content_Type {'NDG_A_SERVICE'},if (exists($DG/instance/URI)) then element URL {escape-uri($DG/instance/URI, true())} else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&amp;datasetID=', true())} else ($DG/moles:dataModelID/moles:repositoryIdentifier),element Description {'The NDG service delivering data via NDG A metadata.'}},element Related_URL {element URL_Content_Type {'GET DATA > CSML'},if (exists($DG/instance)) then element URL {escape-uri($DG/instance/URI, true())} else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&amp;datasetID=', true())} else (),element Description {'The NDG service delivering data via NDG A metadata. Additional tag to be more in line with latest version of GCMD valids'}}) else if ($DG/moles:dataModelID/moles:schemeIdentifier='CDML-0') then  (element Related_URL {  element URL_Content_Type {'NDG_A_SERVICE'},if (exists($DG/instance)) then element URL {escape-uri($DG/instance/URI, true())} else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} else (),element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'}},element Related_URL {element URL_Content_Type {'GET DATA > DX'},if (exists($DG/instance)) then element URL {escape-uri($DG/instance/URI, true())} else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} else (),element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'}}) else if ($DG/moles:dataModelID/moles:schemeIdentifier='URI') then  element Related_URL {element URL {data($DG/moles:instance/moles:URI)},if (exists($DG/moles:instance/moles:instanceComment)) then  element Description {data($DG/moles:instance/moles:instanceComment)}  else  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.'}} else (),for $RelURL_Desc in ($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference)  return element Related_URL {element URL {data($RelURL_Desc)},element Description {concat(data($RelURL_Desc/moles:name), ' - ', data($RelURL_Desc/moles:notes))} },element Metadata_Name {'[CEOS IDN DIF]'},element Metadata_Version {'9.4'},if (exists($DE/moles:dgMetadataProvenance/moles:RecordCreation)) then  element DIF_Creation_Date {data($DE/moles:dgMetadataProvenance/moles:RecordCreation/moles:CreatedDate)} else (),for $MDUpdt in $DE/moles:dgMetadataProvenance/moles:RecordUpdate return  element DIF_Revision_History {concat(data($MDUpdt/moles:UpdateDate), ' - ', data($MDUpdt/moles:UpdateSummary), ' - ', data($MDUpdt/moles:UpdatedBy))},if (exists($DE/moles:dgMetadataProvenance/moles:RecordReview)) then  element Future_DIF_Review_Date {data($DE/moles:dgMetadataProvenance/moles:RecordReview/moles:ReviewDate)} else ()}''' 
     24DublinCoreDEQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
     25declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
     26declare namespace dc='http://purl.org/dc/elements/1.1/'; 
     27declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc'; 
     28declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     29declare variable $gcmd_science_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'}; 
     30declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'}; 
     31declare variable $cf_standard_names as xs:string {'http://www.cgd.ucar.edu/cms/eaton/cf-metadata/standard_name.html'}; 
     32declare variable $iso_topic_list as xs:string {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'}; 
     33 
     34for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[dgDataEntity!='' and dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID'] 
     35return  
     36element oai_dc:dc { 
     37attribute xsi:schemaLocation {'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'}, 
     38element dc:title {string($DE/name)}, 
     39element dc:type {'Dataset'}, 
     40element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, ':DC:', $DE/dgMetadataID/localIdentifier)}, 
     41element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)}, 
     42element dc:date 
     43{ 
     44if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then 
     45for $updatedate in ($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate) 
     46order by xs:dateTime($updatedate) 
     47return data($updatedate[1]) 
     48else 
     49string($DE/(dgMetadataProvenance | DataProvenance)/RecordCreation/CreatedDate)  
     50}, 
     51for $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)  
     52order by $StructuredKeyword 
     53return  
     54element dc:subject {string($StructuredKeyword)}, 
     55 
     56for $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)  
     57order by $StructuredKeyword1 
     58return  
     59element dc:subject {string($StructuredKeyword1)}, 
     60for $DataCreatorRole in $DE/dgDataEntity/dgDataRoles/dgDataCreator/dgRoleHolder  
     61order by $DataCreatorRole/startDate empty least 
     62return  
     63for $DataCreatorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson) 
     64[(dgMetadataID/schemeIdentifier='NDG-B0' 
     65and dgMetadataID/repositoryIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier 
     66and dgMetadataID/localIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] 
     67return  
     68element dc:creator { 
     69if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then 
     70(string($DataCreatorRoleHolder/name)) 
     71else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then 
     72(string(concat(string($DataCreatorRoleHolder/name/initials), ' ', string($DataCreatorRoleHolder/name/familyName)))) 
     73else ('empty content') 
     74}, 
     75for $DataCuratorRole in $DE/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder[not(exists(endDate)) or endDate=''] 
     76order by $DataCuratorRole/startDate empty least 
     77return  
     78for $DataCuratorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson) 
     79[(dgMetadataID/schemeIdentifier='NDG-B0' 
     80and dgMetadataID/repositoryIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier 
     81and dgMetadataID/localIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/localIdentifier)] 
     82return  
     83element dc:publisher { 
     84if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then 
     85(string($DataCuratorRoleHolder/name)) 
     86else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then 
     87(string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName)))) 
     88else ('empty content') 
     89} 
     90}''' 
     91 
     92DIFQuery = '''declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; 
     93declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
     94declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
     95declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
     96 
     97for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ 
     98exists('moles:dgDataEntity')  
     99and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'  
     100and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID'  
     101and moles:dgMetadataID/moles:localIdentifier='LocalID'] 
     102return 
     103element DIF { 
     104attribute xsi:schemaLocation {'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.4.xsd'}, 
     105element Entry_ID {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':DIF:', $DE/moles:dgMetadataID/moles:localIdentifier)}, 
     106element Entry_Title {string($DE/moles:name)}, 
     107element Data_Set_Citation { 
     108for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] 
     109return  
     110for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
     111and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
     112and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
     113return  
     114element Data_Creator { 
     115if (exists($DataCreatorRoleHolder/moles:name/moles:initials)) then  
     116string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName))) 
     117else  
     118string($DataCreatorRoleHolder/moles:abbreviation) 
     119}, 
     120element Dataset_Title {string($DE/moles:name)} 
     121}, 
     122for $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]) 
     123return if (exists($StructuredKeyword/*/moles:dgValidTerm)) then  
     124element Parameters { 
     125element Category {string($StructuredKeyword/*/moles:dgValidTerm)}, 
     126if (exists($StructuredKeyword//moles:dgValidSubterm)  
     127and $StructuredKeyword//moles:dgValidSubterm != ''  
     128and $StructuredKeyword//moles:dgValidSubterm != ' ') then  
     129for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)] 
     130where exists($Subterm/moles:dgValidSubterm) 
     131order by $Subterm/moles:ListLevel 
     132return  
     133if ($Subterm/moles:ListLevel=1) then element Topic {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     134else if ($Subterm/moles:ListLevel=2) then element Term {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     135else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     136else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     137else element GCMD_Science_Valid {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
     138else() 
     139} 
     140else(), 
     141for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[moles:dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) 
     142return  
     143element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)}, 
     144for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ 
     145moles:dgValidTermID/moles:ParentListID!='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'  
     146and  
     147moles:dgValidTermID/moles:ParentListID!='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'  
     148]/moles:dgValidTerm) 
     149return element Keyword {string($Keyword)},  
     150for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID)  
     151return  
     152element Sensor_Name { 
     153for $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)) 
     154return element Short_Name {data($DepDPTAbbrev)}, 
     155for $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)) 
     156return element Long_Name {data($DepDPTName)} 
     157}, 
     158for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID) 
     159return  
     160element Source_Name { 
     161for $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)) 
     162return element Short_Name {data($DepObsStnAbbrev)}, 
     163for $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)) 
     164return element Long_Name {data($DepObsStnName)} 
     165}, 
     166for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgDateRange) 
     167return  
     168element Temporal_Coverage 
     169{ 
     170element Start_Date {data($TemporalRange/moles:DateRangeStart)}, 
     171element End_Date {data($TemporalRange/moles:DateRangeEnd)} 
     172}, 
     173for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea/moles:dgValidTerm) 
     174return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}},  
     175for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure) 
     176return element Data_Set_Progress {data($Data_Set_Progress)}, 
     177for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox) 
     178return  
     179element Spatial_Coverage { 
     180element Southernmost_Latitude {data($BoundingBox/moles:LimitSouth)}, 
     181element Northernmost_Latitude {data($BoundingBox/moles:LimitNorth)}, 
     182element Westernmost_Longitude {data($BoundingBox/moles:LimitWest)}, 
     183element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)} 
     184}, 
     185for $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']) 
     186return element Location {$Location},  
     187for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID) 
     188return  
     189element Project { 
     190for $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) 
     191return  
     192element Short_Name {data($DepActAbbrev)}, 
     193for $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) 
     194return  
     195element Long_Name {data($DepActName)} 
     196}, 
     197if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then  
     198for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule 
     199return  
     200element Access_Constraints { 
     201if (exists($DG/moles:dgGranuleSummary/moles:dgGranuleName)) then  
     202concat('For data granule ', $DG/moles:dgGranuleSummary/moles:dgGranuleName, ': ') 
     203else (), 
     204if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyURL)) then 
     205concat('See access control policy at ', escape-uri($DG/moles:accessControlPolicy/moles:accessControlPolicyURL, true())) 
     206else if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyText)) then 
     207data($DG/moles:accessControlPolicy/moles:accessControlPolicyText) 
     208else  
     209for $securityCondition in $DG/moles:accessControlPolicy/moles:dgSecurityCondition 
     210return 
     211if (exists($securityCondition/moles:conditionExplanationText)) then 
     212concat('Effect: ', data($securityCondition/moles:effect), ' - ', data($securityCondition/moles:conditionExplanationText)) 
     213else concat('Effect: ', data($securityCondition/moles:effect), 'needs ', data($securityCondition/moles:attauthRole), ' from ', data($securityCondition/moles:dgAttributeAuthority)) 
     214} 
     215else (), 
     216if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder)) then 
     217for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder  
     218order by $DataCreatorRole/moles:startDate empty least 
     219return  
     220for $DataCreatorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) 
     221[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
     222and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:repositoryIdentifier 
     223and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:localIdentifier)] 
     224return  
     225element Originating_Center { 
     226if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then 
     227(string($DataCreatorRoleHolder/moles:name)) 
     228else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then 
     229(string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName)))) 
     230else ('empty content') 
     231} 
     232else (), 
     233for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''] 
     234return  
     235for $DataCuratorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
     236and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/*/moles:repositoryIdentifier 
     237and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/*/moles:localIdentifier)] 
     238return  
     239element Data_Center { 
     240element Data_Center_Name { 
     241element Short_Name { 
     242if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
     243string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) 
     244else  
     245string($DataCuratorRoleHolder/moles:abbreviation) 
     246}, 
     247element Long_Name { 
     248if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
     249string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) 
     250else string($DataCuratorRoleHolder/moles:name) 
     251} 
     252}, 
     253if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:URI)) then  
     254element Data_Center_URL {data($DataCuratorRoleHolder/moles:contactDetails/moles:URI)} 
     255else (), 
     256for $DGID in $DE/moles:dgDataEntity/moles:dgDataGranule/moles:dataModelID 
     257return  
     258element Data_Set_ID {concat($DGID/moles:repositoryIdentifier, ':', $DGID/moles:schemeIdentifier, ':', $DGID/moles:localIdentifier)}, 
     259element Personnel { 
     260element Role {'Data Center Contact'}, 
     261if (exists($DataCuratorRoleHolder/name/knownAs)) then  
     262element First_Name {string($DataCuratorRoleHolder/moles:name/moles:knownAs)} 
     263else if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
     264element First_Name {string($DataCuratorRoleHolder/moles:name/moles:initials)} 
     265else (), 
     266element Last_Name { 
     267if (exists($DataCuratorRoleHolder/moles:name/moles:familyName)) then  
     268string($DataCuratorRoleHolder/moles:name/moles:familyName) 
     269else string($DataCuratorRoleHolder/moles:name) 
     270}, 
     271if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then  
     272element Email {string($DataCuratorRole/moles:contactDetails/moles:eMail)} 
     273else  
     274if (exists($DataCuratorRoleHolder/contactDetails/eMail)) then  
     275(element Email {string($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}) 
     276else (), 
     277if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then  
     278element Phone {string($DataCuratorRole/moles:contactDetails/moles:telephone)} 
     279else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then  
     280element Phone {string($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)} 
     281else (), 
     282if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then  
     283element Fax {string($DataCuratorRole/moles:contactDetails/moles:fax)} 
     284else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then  
     285element Fax {string($DataCuratorRoleHolder/moles:contactDetails/moles:fax)} 
     286else (), 
     287if (exists($DataCuratorRole/moles:contactDetails/moles:address)) then  
     288element Contact_Address { 
     289for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline 
     290return element Address {data($addressline)}, 
     291if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then  
     292element City {string($DataCuratorRole/moles:contactDetails/moles:address/moles:city)} 
     293else (), 
     294if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)) then  
     295element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)} 
     296else (), 
     297if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:country)) then  
     298element Country {string($DataCuratorRole/moles:contactDetails/moles:address/moles:country)} 
     299else () 
     300} 
     301else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address)) then  
     302element Contact_Address { 
     303for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline 
     304return element address {data($addressline)}, 
     305if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then  
     306element City {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)} 
     307else (), 
     308if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then  
     309element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:postcode)} 
     310else (), 
     311if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)) then  
     312element Country {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)} 
     313else () 
     314} 
     315else () 
     316} 
     317}, 
     318element Summary {string($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}, 
     319element Related_URL { 
     320element URL_Content_Type {'NDG_B_SERVICE'}, 
     321element URL {data($DE/moles:dgMetadataID/moles:repositoryIdentifier)}, 
     322element Description {'The NDG service for browsing metadata.'} 
     323}, 
     324for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule 
     325return 
     326if ($DG/moles:dataModelID/moles:schemeIdentifier='NDG-A0') then  
     327(element Related_URL { 
     328element URL_Content_Type {'NDG_A_SERVICE'}, 
     329if (exists($DG/instance/URI)) then 
     330element URL {escape-uri($DG/instance/URI, true())} 
     331else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     332element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&amp;datasetID=', true())} 
     333else ($DG/moles:dataModelID/moles:repositoryIdentifier), 
     334element Description {'The NDG service delivering data via NDG A metadata.'} 
     335}, 
     336element Related_URL { 
     337element URL_Content_Type {'GET DATA > CSML'}, 
     338if (exists($DG/instance)) then 
     339element URL {escape-uri($DG/instance/URI, true())} 
     340else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     341element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&amp;datasetID=', true())} 
     342else (), 
     343element Description {'The NDG service delivering data via NDG A metadata. Additional tag to be more in line with latest version of GCMD valids'} 
     344}) 
     345else if ($DG/moles:dataModelID/moles:schemeIdentifier='CDML-0') then  
     346(element Related_URL {  
     347element URL_Content_Type {'NDG_A_SERVICE'}, 
     348if (exists($DG/instance)) then 
     349element URL {escape-uri($DG/instance/URI, true())} 
     350else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     351element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} 
     352else (), 
     353element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} 
     354}, 
     355element Related_URL { 
     356element URL_Content_Type {'GET DATA > DX'}, 
     357if (exists($DG/instance)) then 
     358element URL {escape-uri($DG/instance/URI, true())} 
     359else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     360element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} 
     361else (), 
     362element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} 
     363}) 
     364else if ($DG/moles:dataModelID/moles:schemeIdentifier='URI') then  
     365element Related_URL { 
     366element URL {data($DG/moles:instance/moles:URI)}, 
     367if (exists($DG/moles:instance/moles:instanceComment)) then  
     368element Description {data($DG/moles:instance/moles:instanceComment)}  
     369else  
     370element 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} 
     372else (), 
     373for $RelURL_Desc in ($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference)  
     374return 
     375element Related_URL { 
     376element URL {data($RelURL_Desc)}, 
     377element Description {concat(data($RelURL_Desc/moles:name), ' - ', data($RelURL_Desc/moles:notes))}  
     378}, 
     379element Metadata_Name {'[CEOS IDN DIF]'}, 
     380element Metadata_Version {'9.4'}, 
     381if (exists($DE/moles:dgMetadataProvenance/moles:RecordCreation)) then  
     382element DIF_Creation_Date {data($DE/moles:dgMetadataProvenance/moles:RecordCreation/moles:CreatedDate)} 
     383else (), 
     384for $MDUpdt in $DE/moles:dgMetadataProvenance/moles:RecordUpdate 
     385return  
     386element DIF_Revision_History {concat(data($MDUpdt/moles:UpdateDate), ' - ', data($MDUpdt/moles:UpdateSummary), ' - ', data($MDUpdt/moles:UpdatedBy))}, 
     387if (exists($DE/moles:dgMetadataProvenance/moles:RecordReview)) then  
     388element Future_DIF_Review_Date {data($DE/moles:dgMetadataProvenance/moles:RecordReview/moles:ReviewDate)} 
     389else () 
     390}''' 
    27391 
    28392ISO19139Query = '''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()}}}''' 
  • TI07-MOLES/trunk/v1Schema/Schemae/MOLES1.spp

    r1822 r2008  
    1616                <ExtMountFolder FolderName="C:\Documents and Settings\Kevin\Desktop\Invalid DIFs"/> 
    1717                <ExtMountFolder FolderName="C:\test\DIF2MOLES"/> 
     18                <ExtMountFolder FolderName="C:\test"/> 
    1819        </Folder> 
    1920        <Folder FolderName="XSL Files" ExtStr="xsl;xslt"/> 
Note: See TracChangeset for help on using the changeset viewer.