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

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

Update xqueries:

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