Changeset 4326 for exist/trunk/xquery


Ignore:
Timestamp:
10/10/08 16:24:40 (11 years ago)
Author:
sdonegan
Message:

Updated handling of URLs in conversion from MOLES. SJD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/xquery/moles2dif.xq

    r3841 r4326  
    1 (: This is the xquery to produce a dif document from a full moles database. It is sometimes used for miniMoles, but it's 
    2 main aim should be to produce DIF documents from MOLES for NDG participants. 
    3 Key parameters to be changed when used in anger are 
    4  TargetCollection, Repository ID, LocalID :) 
    5  
    6 declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; 
     1declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; 
    72declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    83declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    94declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
    105 
     6(:  
     7Updated descriptionSection to use from URI to URL in moles doc.. can now return links.. 
     8SJD 10/10/08 
     9:) 
     10 
     11(: Keep this in official lib version :) 
    1112declare variable $targetCollection as xs:string := 'TargetCollection'; 
    1213declare variable $repositoryIdentifier as xs:string := 'RepositoryID'; 
     
    1819declare variable $localIdentifier as xs:string := 'dataent_CIRA'; 
    1920:) 
     21 
     22 
    2023for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    2124        exists('moles:dgDataEntity')  
     
    2427        and moles:dgMetadataID/moles:localIdentifier=$localIdentifier] 
    2528return 
    26     element DIF { 
     29element DIF { 
    2730        attribute xsi:schemaLocation {'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.4.xsd'}, 
    2831        element Entry_ID {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':DIF:', $DE/moles:dgMetadataID/moles:localIdentifier)}, 
     
    3033        element Data_Set_Citation { 
    3134            for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] 
    32                 return  
     35                return 
    3336                    for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
    3437                               and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
    3538                               and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
    3639                        return  
    37                             element Data_Creator { 
     40                            element Dataset_Creator { 
    3841                                if (exists($DataCreatorRoleHolder/moles:name/moles:initials)) then  
    3942                                    string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName))) 
     
    4346            element Dataset_Title {string($DE/moles:name)} 
    4447        }, 
    45         element Personnel {''}, 
    46         element Discipline {''}, 
     48        element Personnel  
     49        {element Role {''}, 
     50        element Last_Name {''} 
     51        }, 
     52        element Discipline { element Discipline_Name {''} }, 
    4753        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]) 
    4854                return if (exists($StructuredKeyword/*/moles:dgValidTerm)) then  
     
    6167                                        else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    6268                                        else element GCMD_Science_Valid {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
    63                         else() 
     69                        else () 
    6470                    } 
    65                 else(), 
     71                else (), 
     72        (: Parameters - this is fail safe :) 
     73        element Parameters { element Category {''}, element Topic {''}, element Term {''} }, 
     74 
     75        (: ISOTopic subcategory :) 
    6676        for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[moles:dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) 
    6777            return  
    6878                element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)}, 
     79 
     80        (: ok from here :) 
    6981        for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ 
    7082        moles:dgValidTermID/moles:ParentListID!='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'   
     
    7284        moles:dgValidTermID/moles:ParentListID!='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'   
    7385        ]/moles:dgValidTerm) 
     86         
    7487        return element Keyword {string($Keyword)},  
    7588        for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID)   
     
    147160                    order by $DataCreatorRole/moles:startDate empty least 
    148161                            return  
    149                                 for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) 
     162                              (:##for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson):) 
     163                                for $DataCreatorRoleHolder in $targetCollection/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) 
    150164                                                [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
    151165                                                and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:repositoryIdentifier 
     
    160174                                } 
    161175        else (), 
     176        (: Data Centre fail safe code in here.. somewhere :) 
    162177        for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''] 
    163178            return  
    164                 for $DataCuratorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
     179                for $DataCuratorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'               
    165180                   and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/*/moles:repositoryIdentifier 
    166181                   and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/*/moles:localIdentifier)] 
     
    245260                                 } 
    246261                        }, 
     262                        (: fail safe... :) 
     263                        element Data_Center {  
     264                        element Data_Center_Name { element Short_Name {''} }, 
     265                        element Personnel { element Role {''}, element Last_Name {''} } 
     266                        }, 
    247267        element Distribution {''}, 
    248268        element Multimedia_Sample {''}, 
     
    269289                            element URL {data($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference/moles:dgSimpleLink/moles:URI)},:) 
    270290                             
    271                         element URL {data($RelURL_Desc/moles:dgSimpleLink/moles:URI)},  
     291                        element URL {data($RelURL_Desc/moles:dgSimpleLink/moles:URL)},  
    272292 
    273293                            (: According to Sue, the description can be the standard definition as served by the NDG vocalb server :) 
     
    275295                         }, 
    276296        element Parent_DIF {''}, 
    277         element IDN_Node {''}, 
     297        element IDN_Node { element Short_Name {''} }, 
    278298        element Originating_Metadata_Node {''},  
    279299        element Metadata_Name {'[CEOS IDN DIF]'}, 
Note: See TracChangeset for help on using the changeset viewer.