source: ndgCommon/trunk/ndg/common/xmldb/xquery/moles2dif.xq @ 4793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/xmldb/xquery/moles2dif.xq@4793
Revision 4793, 28.5 KB checked in by cbyrom, 11 years ago (diff)

Checking in initial codebase for ndgUtils restructure.

Line 
1declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/';
2declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';
3declare namespace moles='http://ndg.nerc.ac.uk/moles';
4declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions';
5
6
7import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'vocab_xquery_lib.xquery';
8import module namespace inputParse='http://ndg.nerc.ac.uk/xquery/lib/inputParse' at 'inputParse_xquery_lib.xquery';
9
10
11(:
12Updated descriptionSection to use from URI to URL in moles doc.. can now return links..
13also RELATED_URLs & data centre names all work with badc dif2moles2dif pipeline, also started to take encode-uri as not using eXist so just cacks up the URI's
14SJD 15/10/08
15:)
16
17(: Keep this in official lib version :)
18(:declare variable collection($targetCollection) := doc('molesOP.xml');
19declare variable $repositoryIdentifier as xs:string := 'Input_Repository_Code';
20declare variable $localIdentifier as xs:string := 'MRMLN00400000061';
21:)
22declare variable $targetCollection as xs:string := 'TargetCollection';
23declare variable $repositoryIdentifier as xs:string := 'RepositoryID';
24declare variable $localIdentifier as xs:string := 'LocalID';
25
26(: Keep
27declare variable collection($targetCollection) as xs:string := '/db/ndg_B_metadata';
28declare variable $repositoryIdentifier as xs:string := 'badc.nerc.ac.uk';
29declare variable $localIdentifier as xs:string := 'dataent_CIRA';
30:)
31
32for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[
33        exists('moles:dgDataEntity')
34        and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'
35        and moles:dgMetadataID/moles:repositoryIdentifier=$repositoryIdentifier
36        and moles:dgMetadataID/moles:localIdentifier=$localIdentifier]
37return
38element DIF {
39        attribute xsi:schemaLocation {'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.4.xsd'},
40        element Entry_ID {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':DIF:', $DE/moles:dgMetadataID/moles:localIdentifier)},
41        element Entry_Title {string($DE/moles:name)},
42        element Data_Set_Citation {
43            for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1]
44                return
45                    for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'
46                               and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier
47                               and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)]
48                        return
49                            element Dataset_Creator {
50                                if (exists($DataCreatorRoleHolder/moles:name/moles:initials)) then
51                                    string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName)))
52                                else
53                                   string($DataCreatorRoleHolder/moles:abbreviation)
54                                },
55            element Dataset_Title {string($DE/moles:name)}
56        },
57        element Personnel
58        {element Role {''},
59        element Last_Name {''}
60        },
61        element Discipline { element Discipline_Name {''} },
62        for $StructuredKeyword in ($DE//(moles:dgStructuredKeyword | moles:dgStdParameterMeasured)[moles:dgValidTermID/moles:ParentListID='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html' and moles:ListLevel = 0])
63                return if (exists($StructuredKeyword/*/moles:dgValidTerm)) then
64                    element Parameters {
65                        element Category {string($StructuredKeyword/*/moles:dgValidTerm)},
66                        if (exists($StructuredKeyword//moles:dgValidSubterm)
67                                and $StructuredKeyword//moles:dgValidSubterm != ''
68                                and $StructuredKeyword//moles:dgValidSubterm != ' ') then
69                        for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)]
70                            where exists($Subterm/moles:dgValidSubterm)
71                            order by $Subterm/moles:ListLevel
72                                return
73                                        if ($Subterm/moles:ListLevel=1) then element Topic {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}
74                                        else if ($Subterm/moles:ListLevel=2) then element Term {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}
75                                        else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}
76                                        else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}
77                                        else element GCMD_Science_Valid {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}
78                        else ()
79                    }
80                else (),
81        (: Parameters - this is fail safe :)
82        element Parameters { element Category {''}, element Topic {''}, element Term {''} },
83
84        (: ISOTopic subcategory :)
85        for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[moles:dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'])
86            return
87                element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)},
88
89        (: ok from here :)
90        for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[
91        moles:dgValidTermID/moles:ParentListID!='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html'
92        and
93        moles:dgValidTermID/moles:ParentListID!='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'
94        ]/moles:dgValidTerm)
95
96        return element Keyword {string($Keyword)},
97        for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID)
98        return
99            element Sensor_Name {
100               (: for $DepDPTAbbrev in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:abbreviation)):)
101                for $DepDPTAbbrev in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:abbreviation))
102                    return element Short_Name {data($DepDPTAbbrev)},
103                (:for $DepDPTName in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:name)):)
104                for $DepDPTName in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:name))
105                    return element Long_Name {data($DepDPTName)}
106                },
107        for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID)
108        return
109            element Source_Name {
110                (:for $DepObsStnAbbrev in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:abbreviation)):)
111                for $DepObsStnAbbrev in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:abbreviation))
112                    return element Short_Name {data($DepObsStnAbbrev)},
113                (:for $DepObsStnName in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:name)):)
114                for $DepObsStnName in distinct-values((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:name))
115                    return element Long_Name {data($DepObsStnName)}
116                },
117    for $TemporalRange in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/(moles:dgTemporalCoverage | moles:dgSpatioTemporalCoverage/moles:dgSpatioTemporalRange/moles:dgTemporalCoverage)/moles:DateRange
118        return
119            element Temporal_Coverage
120                        {
121                        element Start_Date {data($TemporalRange/moles:DateRangeStart)},
122                        element Stop_Date {data($TemporalRange/moles:DateRangeEnd)}
123                        },
124        for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea/moles:dgValidTerm)
125                return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}},
126        for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure)
127                return element Data_Set_Progress {data($Data_Set_Progress)},
128        for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox)
129        return
130            element Spatial_Coverage {
131                    element Southernmost_Latitude {data($BoundingBox/moles:LimitSouth)},
132                    element Northernmost_Latitude {data($BoundingBox/moles:LimitNorth)},
133                    element Westernmost_Longitude {data($BoundingBox/moles:LimitWest)},
134                    element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)}
135                },
136        for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[moles:dgValidTermID/moles:ParentListID='http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_locations.html'])
137                return element Location {$Location},
138        element Data_Resolution {''},
139        for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID)
140        return
141            element Project {
142                for $DepActAbbrev in distinct-values(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:abbreviation)
143                    return
144                        element Short_Name {data($DepActAbbrev)},
145                for $DepActName in distinct-values(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:name)
146                    return
147                        element Long_Name {data($DepActName)}
148                },
149        element Quality {''},
150        if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then
151                for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule
152                    return
153                                element Access_Constraints {
154                                if (exists($DG/moles:dgGranuleSummary/moles:dgGranuleName)) then
155                                    concat('For data granule ', $DG/moles:dgGranuleSummary/moles:dgGranuleName, ': ')
156                                else (),
157                                if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyURL)) then
158                                    concat('See access control policy at ', encode-for-uri($DG/moles:accessControlPolicy/moles:accessControlPolicyURL))
159                                else if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyText)) then
160                                    data($DG/moles:accessControlPolicy/moles:accessControlPolicyText)
161                                 else
162                                     for $securityCondition in $DG/moles:accessControlPolicy/moles:dgSecurityCondition
163                                     return
164                                         if (exists($securityCondition/moles:conditionExplanationText)) then
165                                             concat('Effect: ', data($securityCondition/moles:effect), ' - ', data($securityCondition/moles:conditionExplanationText))
166                                         else concat('Effect: ', data($securityCondition/moles:effect), 'needs ', data($securityCondition/moles:attauthRole), ' from ', data($securityCondition/moles:dgAttributeAuthority))
167                            }
168                else (),
169        element Use_Constraints {''},
170        element Data_Set_Language {''},
171        if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder)) then
172                for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder
173                    order by $DataCreatorRole/moles:startDate empty least
174                            return
175                              (:##for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson):)
176                                for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson)
177                                                [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'
178                                                and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:repositoryIdentifier
179                                                and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/(moles:dgOrganisationID | moles:dgPersonID)/moles:localIdentifier)]
180                                return
181                                        element Originating_Center {
182                                        if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then
183                                                (string($DataCreatorRoleHolder/moles:name))
184                                        else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then
185                                                (string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName))))
186                                        else ('empty content')
187                                }
188        else (),
189        (: Data Centre fail safe code in here.. somewhere :)
190        for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate='']
191            return
192                for $DataCuratorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'
193                   and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/*/moles:repositoryIdentifier
194                   and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/*/moles:localIdentifier)]
195                    return
196                        element Data_Center {
197                        element Data_Center_Name {
198                                element Short_Name {
199                                    if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then
200                                    string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName)))
201                            else
202                                string($DataCuratorRoleHolder/moles:abbreviation)
203                            },
204                        element Long_Name {
205                                if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then
206                                    string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName)))
207                                else string($DataCuratorRoleHolder/moles:name)
208                            }
209                        },
210                        if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:URI)) then
211                                element Data_Center_URL {data($DataCuratorRoleHolder/moles:contactDetails/moles:URI)}
212                        else (),
213                        for $DGID in $DE/moles:dgDataEntity/moles:dgDataGranule/moles:dataModelID
214                        return
215                            element Data_Set_ID {concat($DGID/moles:repositoryIdentifier, ':', $DGID/moles:schemeIdentifier, ':', $DGID/moles:localIdentifier)},
216                        element  Personnel {
217                                element Role {'Data Center Contact'},
218                                if (exists($DataCuratorRoleHolder/name/knownAs)) then
219                                    element First_Name {string($DataCuratorRoleHolder/moles:name/moles:knownAs)}
220                                else if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then
221                                    element First_Name {string($DataCuratorRoleHolder/moles:name/moles:initials)}
222                                 else (),
223                                 element Last_Name {
224                                          if (exists($DataCuratorRoleHolder/moles:name/moles:familyName)) then
225                                              string($DataCuratorRoleHolder/moles:name/moles:familyName)
226                                    else string($DataCuratorRoleHolder/moles:name)
227                                    },
228                                if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then
229                                    element Email {string($DataCuratorRole/moles:contactDetails/moles:eMail)}
230                                else
231                                    if (exists($DataCuratorRoleHolder/contactDetails/eMail)) then
232                                            (element Email {string($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)})
233                                        else (),
234                                if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then
235                                    element Phone {string($DataCuratorRole/moles:contactDetails/moles:telephone)}
236                                else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then
237                                            element Phone {string($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)}
238                                 else (),
239                                if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then
240                                    element Fax {string($DataCuratorRole/moles:contactDetails/moles:fax)}
241                                else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then
242                                            element Fax {string($DataCuratorRoleHolder/moles:contactDetails/moles:fax)}
243                                        else (),
244                                if (exists($DataCuratorRole/moles:contactDetails/moles:address)) then
245                                    element Contact_Address {
246                                        for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline
247                                            return element Address {data($addressline)},
248                                                        if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then
249                                        element City {string($DataCuratorRole/moles:contactDetails/moles:address/moles:city)}
250                                    else (),
251                                    if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)) then
252                                        element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)}
253                                    else (),
254                                     if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:country)) then
255                                         element Country {string($DataCuratorRole/moles:contactDetails/moles:address/moles:country)}
256                                     else ()
257                                     }
258                                else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address)) then
259                                    element Contact_Address {
260                                        for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline
261                                            return element Address {data($addressline)},
262                                                            if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then
263                                            element City {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)}
264                                        else (),
265                                        if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then
266                                            element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:postcode)}
267                                        else (),
268                                         if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)) then
269                                             element Country {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)}
270                                         else ()
271                                     }
272                                else ()
273                                 }
274                        },
275                        (: fail safe... :)
276                        (: SJD Updated to pull straight from dgOrganisation as "backup fail safe" :)
277                        if (exists(collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation)) then
278                            element Data_Center {
279                                element Data_Center_Name {
280                                    element Short_Name {data(collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation/moles:abbreviation)},
281                                    element Long_Name {data(collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation/moles:name)}
282                                },
283                                element Data_Center_URL {data(collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation/moles:contactDetails/moles:URI) cast as xs:anyURI},
284                                element Personnel {
285                                    element Role {''},
286                                    element Last_Name {''}
287                                 }
288                            }
289                        else
290                            (: "old" fail safe :)
291                            element Data_Center {
292                                element Data_Center_Name {
293                                    element Short_Name {''}
294                                  },
295                            element Personnel {
296                                element Role {''},
297                                element Last_Name {''}
298                             }
299                            },
300        element Distribution {''},
301        element Multimedia_Sample {''},
302        element Reference {''},
303        element Summary {string($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)},
304        for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule
305            (: BNL need to make sure we have a function for doing related URLs :)
306            return
307                if ($DG/moles:dataModelID/moles:schemeIdentifier='NDG-A0') then
308                    ()
309                else if ($DG/moles:dataModelID/moles:schemeIdentifier='URI') then
310                    element Related_URL {
311                            element URL {data($DG/moles:instance/moles:URI)},
312                            if (exists($DG/moles:instance/moles:instanceComment)) then
313                                    element Description {data($DG/moles:instance/moles:instanceComment)}
314                            else
315                                    element Description {'URL to aid in delivering data. Note that this may point directly to the data or, more likely, point to the web site of the curator.'}
316                            }
317            else (),
318             (: SJD: need to put in some logic to detect whether its moles with a straight dgSimpleLink or complex dgSimpleLink/name|URL. grrrrr.  :)
319             (: SJD: following logic ensures only moles 1.4 with both name AND url entered (i.e. valid ones!) are used... :)
320                for $RelURL_Desc in (1 to count($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference/moles:dgSimpleLink/moles:name/../moles:URL))
321            return
322                element Related_URL{
323                    element URL {data($DE/moles:dgMetadataDescription/moles:descriptionSection[$RelURL_Desc]/moles:descriptionOnlineReference/moles:dgSimpleLink/moles:name/../moles:URL) cast as xs:anyURI},
324                    element Description {data($DE/moles:dgMetadataDescription/moles:descriptionSection[$RelURL_Desc]/moles:descriptionOnlineReference/moles:dgSimpleLink/moles:name)}
325                },
326
327            (: SJD: following logic ensures only moles 1.3 with useable url in dgSiimpleLink entered (i.e. valid ones!) are used... :)
328            if (count($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference/moles:dgSimpleLink/moles:name|$DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference/moles:dgSimpleLink/moles:URI) = 0) then
329
330                for $RelURL_Desc in (1 to count($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference/moles:dgSimpleLink))
331                return
332                    element Related_URL{
333                        element URL {data($DE/moles:dgMetadataDescription/moles:descriptionSection[$RelURL_Desc]/moles:descriptionOnlineReference/moles:dgSimpleLink) cast as xs:anyURI},
334                        element Description {data('RELATED_URL_DUMMY')}
335                    }
336            else (),
337
338        element Parent_DIF {''},
339        element IDN_Node { element Short_Name {''} },
340        element Originating_Metadata_Node {''},
341        element Metadata_Name {'[CEOS IDN DIF]'},
342        element Metadata_Version {'9.4'},
343        if  (exists($DE/moles:dgMetadataProvenance/moles:RecordCreation)) then
344                element DIF_Creation_Date {data($DE/moles:dgMetadataProvenance/moles:RecordCreation/moles:CreatedDate)}
345        else (),
346        for $MDUpdt in $DE/moles:dgMetadataProvenance/moles:RecordUpdate
347        return
348            element DIF_Revision_History {concat(data($MDUpdt/moles:UpdateDate), ' - ', data($MDUpdt/moles:UpdateSummary), ' - ', data($MDUpdt/moles:UpdatedBy))},
349        if  (exists($DE/moles:dgMetadataProvenance/moles:RecordReview)) then
350                element Future_DIF_Review_Date {data($DE/moles:dgMetadataProvenance/moles:RecordReview/moles:ReviewDate)}
351        else ()
352        } (:    </DIF> :)
Note: See TracBrowser for help on using the repository browser.