source: TI07-MOLES/trunk/DublinCore/XQuery/NDG-DublinCore.xquery @ 2008

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/DublinCore/XQuery/NDG-DublinCore.xquery@2008
Revision 2008, 4.3 KB checked in by ko23, 15 years ago (diff)

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1declare default element namespace 'http://ndg.nerc.ac.uk/moles';
2declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';
3declare namespace dc='http://purl.org/dc/elements/1.1/';
4declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc';
5declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'};
6declare variable $gcmd_science_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'};
7declare variable $gcmd_project_valids as xs:string {'http://gcmd.gsfc.nasa.gov/Resources/valids/projects.html'};
8declare variable $cf_standard_names as xs:string {'http://www.cgd.ucar.edu/cms/eaton/cf-metadata/standard_name.html'};
9declare variable $iso_topic_list as xs:string {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'};
10
11for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[dgDataEntity!='' and dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='badc.nerc.ac.uk' and dgMetadataID/localIdentifier='dataent1']
12return
13element oai_dc:dc {
14        attribute xsi:schemaLocation {'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'},
15        element dc:title {string($DE/name)},
16        element dc:type {'Dataset'},
17        element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, ':DC:', $DE/dgMetadataID/localIdentifier)},
18        element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)},
19        element dc:date
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                },
28        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)
29                order by $StructuredKeyword
30                return
31                element dc:subject {string($StructuredKeyword)},
32       
33        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)
34                order by $StructuredKeyword1
35        return
36                element dc:subject  {string($StructuredKeyword1)},
37        for $DataCreatorRole in $DE/dgDataEntity/dgDataRoles/dgDataCreator/dgRoleHolder
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> :)
Note: See TracBrowser for help on using the repository browser.