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

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

Corrected oai_dc namespace declaration : needs to end in a slash

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery';
2import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery';
3declare default element namespace 'http://ndg.nerc.ac.uk/moles';
4declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';
5declare namespace dc='http://purl.org/dc/elements/1.1/';
6declare namespace oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc/';
7declare variable $targetCollection as xs:string {'TargetCollection'};
8declare variable $repositoryIdentifier as xs:string {'RepositoryID'};
9declare variable $localIdentifier as xs:string {'LocalID'};
10
11for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[
12exists('dgDataEntity')
13and dgMetadataID/schemeIdentifier='NDG-B0'
14and dgMetadataID/repositoryIdentifier=$repositoryIdentifier
15and dgMetadataID/localIdentifier=$localIdentifier]
16return
17element oai_dc:dc {
18        attribute xsi:schemaLocation {'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'},
19        element dc:title {string($DE/name)},
20        element dc:type {'Dataset'},
21        element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, $utillib:moles_id_separator, 'DC', $utillib:moles_id_separator, $DE/dgMetadataID/localIdentifier)},
22        element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)},
23        element dc:date
24                {
25                if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then
26                        for $updatedate in ($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)
27                                order by xs:dateTime($updatedate)
28                        return data($updatedate[1])
29                else
30                        string($DE/(dgMetadataProvenance | DataProvenance)/RecordCreation/CreatedDate)
31                },
32        for $StructuredKeyword in distinct-values($DE/dgStructuredKeyword[
33        voclib:spot-vocab($voclib:cf_standard_names, dgValidTermID/ParentListID)
34        or voclib:spot-vocab($voclib:gcmd_science_valids, dgValidTermID/ParentListID)
35        or voclib:spot-vocab($voclib:gcmd_project_valids, dgValidTermID/ParentListID)
36        or voclib:spot-vocab($voclib:iso_topic_list, dgValidTermID/ParentListID)
37        or voclib:spot-vocab($voclib:bodc_parameter_usage_vocab, dgValidTermID/ParentListID)
38        or voclib:spot-vocab($voclib:bodc_parameter_discovery_vocab, dgValidTermID/ParentListID)
39        ]/dgValidTerm)
40        order by $StructuredKeyword
41        return
42                element dc:subject {string($StructuredKeyword)},
43       
44        for $StructuredKeyword1 in distinct-values($DE/dgDataEntity/dgDataSummary/dgParameterSummary/dgStdParameterMeasured[
45        voclib:spot-vocab($voclib:gcmd_science_valids, dgValidTermID/ParentListID)
46        or voclib:spot-vocab($voclib:gcmd_project_valids, dgValidTermID/ParentListID)
47        or voclib:spot-vocab($voclib:bodc_parameter_usage_vocab, dgValidTermID/ParentListID)
48        or voclib:spot-vocab($voclib:bodc_parameter_discovery_vocab, dgValidTermID/ParentListID)
49        ]/dgValidTerm)
50                order by $StructuredKeyword1
51        return
52                element dc:subject  {string($StructuredKeyword1)},
53        for $DataCreatorRole in $DE/dgDataEntity/dgDataRoles/dgDataCreator/dgRoleHolder
54                order by $DataCreatorRole/startDate empty least
55        return
56                for $DataCreatorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson)
57                        [(dgMetadataID/schemeIdentifier='NDG-B0'
58                        and dgMetadataID/repositoryIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier
59                        and dgMetadataID/localIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/localIdentifier)]
60                return
61                        element dc:creator {
62                                if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then
63                                        (string($DataCreatorRoleHolder/name))
64                                else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then
65                                        (string(concat(string($DataCreatorRoleHolder/name/initials), ' ', string($DataCreatorRoleHolder/name/familyName))))
66                                else ('empty content')
67                        },
68        for $DataCuratorRole in $DE/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder[not(exists(endDate)) or endDate='']
69                order by $DataCuratorRole/startDate empty least
70        return
71                for $DataCuratorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson)
72                        [(dgMetadataID/schemeIdentifier='NDG-B0'
73                        and dgMetadataID/repositoryIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier
74                        and dgMetadataID/localIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/localIdentifier)]
75                return
76                        element dc:publisher {
77                                if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then
78                                        (string($DataCuratorRoleHolder/name))
79                                else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then
80                                        (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName))))
81                                else ('empty content')
82                        }
83}  (: </oai_dc:dc> :)
Note: See TracBrowser for help on using the repository browser.