source: TI07-MOLES/trunk/MDIP/XQueries/NDG-MDIP.xquery @ 2171

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/MDIP/XQueries/NDG-MDIP.xquery@2171
Revision 2171, 2.2 KB checked in by ko23, 14 years ago (diff)

Refactoring intermediate

Line 
1import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery';
2declare default element namespace 'http://www.dassh.ac.uk';
3declare namespace moles='http://ndg.nerc.ac.uk/moles';
4declare namespace gco='http://www.isotc211.org/2005/gco';
5declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';
6declare variable $targetCollection as xs:string {'TargetCollection'};
7declare variable $repositoryIdentifier as xs:string {'RepositoryID'};
8declare variable $localIdentifier as xs:string {'LocalID'};
9
10declare variable $ISO_639-2_ns as xs:string{$voclib:ISO_639-2_ns};
11declare variable $ISO_3166_ns as xs:string{$voclib:ISO_3166_ns};
12
13for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[
14        exists('moles:dgDataEntity')
15        and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'
16        and moles:dgMetadataID/moles:repositoryIdentifier=$repositoryIdentifier
17        and moles:dgMetadataID/moles:localIdentifier=$localIdentifier]
18return
19element Metadata {
20        element Title {data($DE/moles:name)},
21        if (exists($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDatasetLanguage)) then
22                for $lang in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDatasetLanguage
23                return
24                        element Language{
25                                element LanguageName {data($lang/dgValidTerm)},
26                                element LanguageVocab {data($lang/dgValidTermID/ParentListID)},
27                                element LanguageCode {data($lang/dgValidTermID/TermID)}
28                        }
29                               
30        else (),
31
32        element Abstract {},
33        for $isoTopic in $DE/moles:dgStructuredKeyword[moles:dgValidTermID/moles:ParentListID='']
34        return element TopicCategory {},
35        for $subject in distinct-values($DE/dgDataEntity/dgDataSummary/dgParameterSummary/dgStdParameterMeasured[
36        voclib:spot-vocab($voclib:gcmd_science_valids, dgValidTermID/ParentListID)
37        or voclib:spot-vocab($voclib:gcmd_project_valids, dgValidTermID/ParentListID)
38        or voclib:spot-vocab($voclib:bodc_parameter_usage_vocab, dgValidTermID/ParentListID)
39        or voclib:spot-vocab($voclib:bodc_parameter_discovery_vocab, dgValidTermID/ParentListID)
40        ]/dgValidTerm)
41        return element Subject {$subject},
42        element Date {
43                element DatasetStartDate {},
44                element DatasetEndDate {}
45        }
46}
Note: See TracBrowser for help on using the repository browser.