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

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

Update to give what was wanted as well as what was needed

  • 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/';
7(:
8declare variable $targetCollection as xs:string {'TargetCollection'};
9declare variable $repositoryIdentifier as xs:string {'RepositoryID'};
10declare variable $localIdentifier as xs:string {'LocalID'};
11:)
12
13declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'};
14declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'};
15declare variable $localIdentifier as xs:string {'dataent_chablis'};
16
17for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[
18exists('dgDataEntity')
19and dgMetadataID/schemeIdentifier='NDG-B0'
20and dgMetadataID/repositoryIdentifier=$repositoryIdentifier
21and dgMetadataID/localIdentifier=$localIdentifier]
22return
23element oai_dc:dc {
24        attribute xsi:schemaLocation {'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'},
25        element dc:title {string($DE/name)},
26        element dc:type {'Dataset'},
27        element dc:identifier {concat($DE/dgMetadataID/repositoryIdentifier, $utillib:moles_id_separator, 'DC', $utillib:moles_id_separator, $DE/dgMetadataID/localIdentifier)},
28        for $identifiers in $DE/dgMetadataDescription/descriptionSection/descriptionOnlineReference[
29        voclib:spot-vocab($voclib:ndg_online_reference_classes_vocab, dgReferenceClass/dgValidTermID/ParentListID)
30        and
31        dgReferenceClass/dgValidTerm='DataPage']
32        return element dc:identifier {data($identifiers/dgSimpleLink/URI)},
33        element dc:description {string($DE/dgMetadataDescription/abstract/abstractText)},
34        element dc:date
35                {
36                if (exists($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)) then
37                        for $updatedate in ($DE/(dgMetadataProvenance | DataProvenance)/RecordUpdate/UpdateDate)
38                                order by xs:date($updatedate)
39                        return data($updatedate[1])
40                else
41                        string($DE/(dgMetadataProvenance | DataProvenance)/RecordCreation/CreatedDate)
42                },
43        for $StructuredKeyword in distinct-values($DE/dgStructuredKeyword[
44        voclib:spot-vocab($voclib:cf_standard_names, dgValidTermID/ParentListID)
45        or 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:iso_topic_list, dgValidTermID/ParentListID)
48        or voclib:spot-vocab($voclib:bodc_parameter_usage_vocab, dgValidTermID/ParentListID)
49        or voclib:spot-vocab($voclib:bodc_parameter_discovery_vocab, dgValidTermID/ParentListID)
50        ]/dgValidTerm)
51        order by $StructuredKeyword
52        return
53                element dc:subject {string($StructuredKeyword)},
54       
55        for $StructuredKeyword1 in distinct-values($DE/dgDataEntity/dgDataSummary/dgParameterSummary/dgStdParameterMeasured[
56        voclib:spot-vocab($voclib:gcmd_science_valids, dgValidTermID/ParentListID)
57        or voclib:spot-vocab($voclib:gcmd_project_valids, dgValidTermID/ParentListID)
58        or voclib:spot-vocab($voclib:bodc_parameter_usage_vocab, dgValidTermID/ParentListID)
59        or voclib:spot-vocab($voclib:bodc_parameter_discovery_vocab, dgValidTermID/ParentListID)
60        ]/dgValidTerm)
61                order by $StructuredKeyword1
62        return
63                element dc:subject  {string($StructuredKeyword1)},
64        for $DataCreatorRole in $DE/dgDataEntity/dgDataRoles/dgDataCreator/dgRoleHolder
65                order by $DataCreatorRole/startDate empty least
66        return
67                for $DataCreatorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson)
68                        [(dgMetadataID/schemeIdentifier='NDG-B0'
69                        and dgMetadataID/repositoryIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier
70                        and dgMetadataID/localIdentifier=$DataCreatorRole/(dgOrganisationID | dgPersonID)/localIdentifier)]
71                return
72                        element dc:creator {
73                                if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then
74                                        (string($DataCreatorRoleHolder/name))
75                                else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then
76                                        (string(concat(string($DataCreatorRoleHolder/name/initials), ' ', string($DataCreatorRoleHolder/name/familyName))))
77                                else ('empty content')
78                        },
79        for $DataCuratorRole in $DE/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder[not(exists(endDate)) or endDate='']
80                order by $DataCuratorRole/startDate empty least
81        return
82                for $DataCuratorRoleHolder in collection($targetCollection)/dgMetadata/(dgOrganisation | dgPerson)
83                        [(dgMetadataID/schemeIdentifier='NDG-B0'
84                        and dgMetadataID/repositoryIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/repositoryIdentifier
85                        and dgMetadataID/localIdentifier=$DataCuratorRole/(dgOrganisationID | dgPersonID)/localIdentifier)]
86                return
87                        element dc:publisher {
88                                if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then
89                                        (string($DataCuratorRoleHolder/name))
90                                else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then
91                                        (string(concat(string($DataCuratorRoleHolder/name/initials), ' ', string($DataCuratorRoleHolder/name/familyName))))
92                                else ('empty content')
93}
94}  (: </oai_dc:dc> :)
Note: See TracBrowser for help on using the repository browser.