source: exist/trunk/xquery/moles2dif.xq @ 4436

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/xquery/moles2dif.xq@4436
Revision 4436, 28.0 KB checked in by cbyrom, 12 years ago (diff)

Remove unneccesary xquery libs from xqueries + fix moles2dif - removing
hidden characters which stopped it from running.

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