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

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

Fix XPATH expression to include full path + fix typo.

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