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

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

Refactoring - working versions. Still slow though.

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