|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | | -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
3 | | - xmlns:exslt="http://exslt.org/common" xmlns:geonet="http://www.fao.org/geonetwork" |
4 | | - xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:srv="http://www.isotc211.org/2005/srv" |
5 | | - xmlns:gmd="http://www.isotc211.org/2005/gmd" version="2.0" exclude-result-prefixes="exslt"> |
6 | | - |
7 | | - <xsl:import href="process-utility.xsl"/> |
8 | | - |
9 | | - <!-- i18n information --> |
10 | | - <xsl:variable name="add-extent-loc"> |
11 | | - <msg id="a" xml:lang="en">Keyword field contains place keywords (ie.</msg> |
12 | | - <msg id="b" xml:lang="en">). Try to compute metadata extent using thesaurus.</msg> |
13 | | - <msg id="a" xml:lang="fr">Certains mots clés sont de type géographique (ie.</msg> |
14 | | - <msg id="b" xml:lang="fr">). Exécuter cette action pour essayer de calculer l'emprise à partir des thésaurus.</msg> |
15 | | - </xsl:variable> |
16 | | - |
17 | | - <!-- GeoNetwork base url --> |
18 | | - <xsl:param name="gurl" select="'http://localhost:8080/geonetwork'"/> |
19 | | - |
20 | | - <!-- The UI language. Thesaurus search is made according to GUI language --> |
21 | | - <xsl:param name="lang" select="'en'"/> |
22 | | - |
23 | | - <!-- Replace or not existing extent --> |
24 | | - <xsl:param name="replace" select="'0'"/> |
25 | | - |
26 | | - |
27 | | - <xsl:variable name="replaceMode" |
28 | | - select="geonet:parseBoolean($replace)"/> |
29 | | - <xsl:variable name="serviceUrl" |
30 | | - select="concat($gurl, '/srv/', $lang, '/xml.search.keywords?pNewSearch=true&pTypeSearch=2&pKeyword=')"/> |
31 | | - |
32 | | - |
33 | | - <xsl:template name="list-add-extent-from-geokeywords"> |
34 | | - <suggestion process="add-extent-from-geokeywords"/> |
35 | | - </xsl:template> |
36 | | - |
37 | | - |
38 | | - <!-- Analyze the metadata record and return available suggestion |
39 | | - for that process --> |
40 | | - <xsl:template name="analyze-add-extent-from-geokeywords"> |
41 | | - <xsl:param name="root"/> |
42 | | - |
43 | | - <xsl:variable name="extentDescription" |
44 | | - select="string-join($root//gmd:EX_Extent/gmd:description/gco:CharacterString, ' ')"/> |
45 | | - |
46 | | - <xsl:variable name="geoKeywords" |
47 | | - select="$root//gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword[ |
48 | | - not(gco:CharacterString/@gco:nilReason) |
49 | | - and not(contains($extentDescription, gco:CharacterString)) |
50 | | - and ../gmd:type/gmd:MD_KeywordTypeCode/@codeListValue='place']"/> |
51 | | - <xsl:if test="$geoKeywords"> |
52 | | - <suggestion process="add-extent-from-geokeywords" id="{generate-id()}" category="keyword" target="extent"> |
53 | | - <name> |
54 | | - <xsl:value-of select="geonet:i18n($add-extent-loc, 'a', $guiLang)"/><xsl:value-of |
55 | | - select="string-join($geoKeywords, ', ')"/> |
56 | | - <xsl:value-of select="geonet:i18n($add-extent-loc, 'b', $guiLang)"/> |
57 | | - </name> |
58 | | - <operational>true</operational> |
59 | | - <params>{gurl:{type:'string', defaultValue:'<xsl:value-of select="$gurl"/>'}, |
60 | | - lang:{type:'string', defaultValue:'<xsl:value-of select="$lang"/>'}, |
61 | | - replace:{type:'boolean', defaultValue:'<xsl:value-of select="$replace"/>'}} |
62 | | - </params> |
63 | | - </suggestion> |
64 | | - </xsl:if> |
65 | | - |
66 | | - </xsl:template> |
67 | | - |
68 | | - |
69 | | - <!-- Do a copy of every nodes and attributes --> |
70 | | - <xsl:template match="@*|node()"> |
71 | | - <xsl:copy> |
72 | | - <xsl:apply-templates select="@*|node()"/> |
73 | | - </xsl:copy> |
74 | | - </xsl:template> |
75 | | - |
76 | | - <!-- Remove geonet:* elements. --> |
77 | | - <xsl:template match="geonet:*" priority="2"/> |
78 | | - |
79 | | - <xsl:template |
80 | | - match="gmd:identificationInfo/gmd:MD_DataIdentification| |
81 | | - gmd:identificationInfo/*[@gco:isoType='gmd:MD_DataIdentification']| |
82 | | - gmd:identificationInfo/srv:SV_ServiceIdentification| |
83 | | - gmd:identificationInfo/*[@gco:isoType='srv:SV_ServiceIdentification']" |
84 | | - priority="2"> |
| 2 | +<!-- |
| 3 | + ~ Copyright (C) 2001-2016 Food and Agriculture Organization of the |
| 4 | + ~ United Nations (FAO-UN), United Nations World Food Programme (WFP) |
| 5 | + ~ and United Nations Environment Programme (UNEP) |
| 6 | + ~ |
| 7 | + ~ This program is free software; you can redistribute it and/or modify |
| 8 | + ~ it under the terms of the GNU General Public License as published by |
| 9 | + ~ the Free Software Foundation; either version 2 of the License, or (at |
| 10 | + ~ your option) any later version. |
| 11 | + ~ |
| 12 | + ~ This program is distributed in the hope that it will be useful, but |
| 13 | + ~ WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | + ~ General Public License for more details. |
| 16 | + ~ |
| 17 | + ~ You should have received a copy of the GNU General Public License |
| 18 | + ~ along with this program; if not, write to the Free Software |
| 19 | + ~ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
| 20 | + ~ |
| 21 | + ~ Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2, |
| 22 | + ~ Rome - Italy. email: geonetwork@osgeo.org |
| 23 | + --> |
85 | 24 |
|
86 | | - <xsl:variable name="srv" |
87 | | - select="local-name(.)='SV_ServiceIdentification' |
88 | | - or @gco:isoType='srv:SV_ServiceIdentification'"/> |
89 | | - |
90 | | - <xsl:copy> |
91 | | - <xsl:copy-of select="@*"/> |
92 | | - <!-- Copy all elements from AbstractMD_IdentificationType--> |
93 | | - <xsl:copy-of |
94 | | - select="gmd:citation| |
95 | | - gmd:abstract| |
96 | | - gmd:purpose| |
97 | | - gmd:credit| |
98 | | - gmd:status| |
99 | | - gmd:pointOfContact| |
100 | | - gmd:resourceMaintenance| |
101 | | - gmd:graphicOverview| |
102 | | - gmd:resourceFormat| |
103 | | - gmd:descriptiveKeywords| |
104 | | - gmd:resourceSpecificUsage| |
105 | | - gmd:resourceConstraints| |
106 | | - gmd:aggregationInfo |
107 | | - "/> |
108 | | - |
109 | | - <!-- Data --> |
110 | | - <xsl:copy-of |
111 | | - select="gmd:spatialRepresentationType| |
112 | | - gmd:spatialResolution| |
113 | | - gmd:language| |
114 | | - gmd:characterSet| |
115 | | - gmd:topicCategory| |
116 | | - gmd:environmentDescription |
117 | | - "/> |
118 | | - |
119 | | - <!-- Service --> |
120 | | - <xsl:copy-of |
121 | | - select="srv:serviceType| |
122 | | - srv:serviceTypeVersion| |
123 | | - srv:accessProperties| |
124 | | - srv:restrictions| |
125 | | - srv:keywords |
126 | | - "/> |
127 | | - |
128 | | - <!-- Keep existing extent and compute |
129 | | - from keywords --> |
130 | | - |
131 | | - <!-- replace or add extent. Default mode is add. |
132 | | - All extent element are processed and if a geographicElement is found, |
133 | | - it will be removed. Description, verticalElement and temporalElement |
134 | | - are preserved. |
135 | | -
|
136 | | - GeographicElement element having BoundingPolygon are preserved. |
137 | | - --> |
138 | | - <xsl:choose> |
139 | | - <xsl:when test="$replaceMode"> |
140 | | - <xsl:for-each select="srv:extent|gmd:extent"> |
141 | | - <xsl:if |
142 | | - test="gmd:EX_Extent/gmd:temporalElement or gmd:EX_Extent/gmd:verticalElement |
143 | | - or gmd:EX_Extent/gmd:geographicElement[gmd:EX_BoundingPolygon]"> |
144 | | - <xsl:copy> |
145 | | - <xsl:copy-of select="gmd:EX_Extent"/> |
146 | | - </xsl:copy> |
147 | | - </xsl:if> |
148 | | - </xsl:for-each> |
149 | | - </xsl:when> |
150 | | - <xsl:otherwise> |
151 | | - <xsl:copy-of select="srv:extent|gmd:extent"/> |
152 | | - </xsl:otherwise> |
153 | | - </xsl:choose> |
154 | | - |
155 | | - <!-- New extent position is after existing ones. --> |
156 | | - <xsl:call-template name="add-extent"> |
157 | | - <xsl:with-param name="srv" select="$srv"/> |
158 | | - </xsl:call-template> |
159 | | - |
160 | | - <!-- End of data --> |
161 | | - <xsl:copy-of select="gmd:supplementalInformation"/> |
162 | | - |
163 | | - <!-- End of service --> |
164 | | - <xsl:copy-of |
165 | | - select="srv:coupledResource| |
166 | | - srv:couplingType| |
167 | | - srv:containsOperations| |
168 | | - srv:operatesOn |
169 | | - "/> |
170 | | - |
171 | | - <!-- Note: When applying this stylesheet |
172 | | - to an ISO profil having a new substitute for |
173 | | - MD_Identification, profil specific element copy. |
174 | | - --> |
175 | | - <xsl:for-each |
176 | | - select="*[namespace-uri()!='http://www.isotc211.org/2005/gmd' and namespace-uri()!='http://www.isotc211.org/2005/srv']"> |
177 | | - <xsl:copy-of select="."/> |
178 | | - </xsl:for-each> |
179 | | - </xsl:copy> |
180 | | - </xsl:template> |
181 | | - |
182 | | - |
183 | | - <!-- Loop on all non empty keywords --> |
184 | | - <xsl:template name="add-extent"> |
185 | | - <xsl:param name="srv" select="false()"/> |
186 | | - <xsl:for-each |
187 | | - select="gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword[not(gco:CharacterString/@gco:nilReason)]"> |
188 | | - |
189 | | - <xsl:call-template name="get-bbox"> |
190 | | - <xsl:with-param name="word" select="gco:CharacterString"/> |
191 | | - <xsl:with-param name="srv" select="$srv"/> |
192 | | - </xsl:call-template> |
193 | | - |
194 | | - </xsl:for-each> |
195 | | - </xsl:template> |
196 | | - |
197 | | - |
198 | | - <!-- Search into current thesaurus and look for a bounding box --> |
199 | | - <xsl:template name="get-bbox"> |
200 | | - <xsl:param name="word"/> |
201 | | - <xsl:param name="srv" select="false()"/> |
202 | | - |
203 | | - <!-- Get keyword information --> |
204 | | - <xsl:variable name="keyword" select="document(concat($serviceUrl, gco:CharacterString))"/> |
205 | | - <xsl:variable name="knode" select="exslt:node-set($keyword)"/> |
206 | | - |
207 | | - <!-- It should be one but if one keyword is found in more |
208 | | - thant one thesaurus, then each will be processed.--> |
209 | | - <xsl:for-each select="$knode/response/descKeys/keyword"> |
210 | | - <xsl:if test="geo"> |
211 | | - <xsl:choose> |
212 | | - <xsl:when test="$srv"> |
213 | | - <srv:extent> |
214 | | - <xsl:copy-of select="geonet:make-iso-extent(geo/west, geo/south, geo/east, geo/north, $word)"/> |
215 | | - </srv:extent> |
216 | | - </xsl:when> |
217 | | - <xsl:otherwise> |
218 | | - <gmd:extent> |
219 | | - <xsl:copy-of select="geonet:make-iso-extent(geo/west, geo/south, geo/east, geo/north, $word)"/> |
220 | | - </gmd:extent> |
221 | | - </xsl:otherwise> |
222 | | - </xsl:choose> |
223 | | - </xsl:if> |
224 | | - </xsl:for-each> |
225 | | - </xsl:template> |
| 25 | +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 26 | + version="2.0" exclude-result-prefixes="#all"> |
| 27 | + <xsl:import href="../../iso19139/process/add-extent-from-geokeywords.xsl"/> |
226 | 28 |
|
227 | 29 | </xsl:stylesheet> |
0 commit comments