-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlanguage-index-fields.xsl
418 lines (322 loc) · 18.8 KB
/
language-index-fields.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gml="http://www.opengis.net/gml"
xmlns:srv="http://www.isotc211.org/2005/srv"
xmlns:java="java:org.fao.geonet.util.XslUtil"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gvq="http://www.geoviqua.org/QualityInformationModel/4.0">
<!--This file defines what parts of the metadata are indexed by Lucene
Searches can be conducted on indexes defined here.
The Field@name attribute defines the name of the search variable.
If a variable has to be maintained in the user session, it needs to be
added to the GeoNetwork constants in the Java source code.
Please keep indexes consistent among metadata standards if they should
work accross different metadata resources -->
<!-- ========================================================================================= -->
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" />
<xsl:include href="convert/functions.xsl"/>
<!-- ========================================================================================= -->
<xsl:variable name="isoDocLangId">
<xsl:call-template name="langId19139"/>
</xsl:variable>
<xsl:template match="/">
<Documents>
<xsl:for-each select="/*[name(.)='gvq:GVQ_Metadata' or @gco:isoType='gvq:GVQ_Metadata']/gmd:locale/gmd:PT_Locale">
<xsl:call-template name="document">
<xsl:with-param name="isoLangId" select="java:threeCharLangCode(normalize-space(string(gmd:languageCode/gmd:LanguageCode/@codeListValue)))"></xsl:with-param>
<xsl:with-param name="langId" select="@id"></xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<xsl:if test="count(/*[name(.)='gvq:GVQ_Metadata' or @gco:isoType='gvq:GVQ_Metadata']/gmd:locale/gmd:PT_Locale//gmd:LanguageCode[@codeListValue = $isoDocLangId]) = 0">
<xsl:call-template name="document">
<xsl:with-param name="isoLangId" select="$isoDocLangId"></xsl:with-param>
<xsl:with-param name="langId" select="java:twoCharLangCode(normalize-space(string($isoDocLangId)))"></xsl:with-param>
</xsl:call-template>
</xsl:if>
</Documents>
</xsl:template>
<!-- ========================================================================================= -->
<xsl:template name="document">
<xsl:param name="isoLangId"/>
<xsl:param name="langId"/>
<Document locale="{$isoLangId}">
<Field name="_locale" string="{$isoLangId}" store="true" index="true"/>
<Field name="_docLocale" string="{$isoDocLangId}" store="true" index="true"/>
<xsl:variable name="poundLangId" select="concat('#',$langId)" />
<xsl:variable name="_defaultTitle">
<xsl:call-template name="defaultTitle">
<xsl:with-param name="isoDocLangId" select="$isoLangId"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$isoLangId!=$isoDocLangId">
<!-- not tokenized title for sorting -->
<Field name="_defaultTitle" string="{string($_defaultTitle)}" store="true" index="true" />
</xsl:if>
<xsl:variable name="title"
select="/*[name(.)='gvq:GVQ_Metadata' or @gco:isoType='gvq:GVQ_Metadata']/gmd:identificationInfo//gmd:citation//gmd:title//gmd:LocalisedCharacterString[@locale=$poundLangId]"/>
<!-- not tokenized title for sorting -->
<xsl:choose>
<xsl:when test="normalize-space($title) = ''">
<Field name="_title" string="{string($_defaultTitle)}" store="true" index="true" />
</xsl:when>
<xsl:otherwise>
<Field name="_title" string="{string($title)}" store="true" index="true" />
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="/*[name(.)='gvq:GVQ_Metadata' or @gco:isoType='gvq:GVQ_Metadata']" mode="metadata">
<xsl:with-param name="langId" select="$poundLangId"/>
</xsl:apply-templates>
</Document>
</xsl:template>
<!-- ========================================================================================= -->
<xsl:template match="*" mode="metadata">
<xsl:param name="langId" />
<!-- === Data or Service Identification === -->
<!-- the double // here seems needed to index MD_DataIdentification when
it is nested in a SV_ServiceIdentification class -->
<xsl:for-each select="gmd:identificationInfo/gmd:MD_DataIdentification|
gmd:identificationInfo/*[@gco:isoType='gmd:MD_DataIdentification']|
gmd:identificationInfo/srv:SV_ServiceIdentification|
gmd:identificationInfo/*[@gco:isoType='srv:SV_ServiceIdentification']">
<xsl:for-each select="gmd:citation/gmd:CI_Citation">
<xsl:for-each select="gmd:identifier/gmd:MD_Identifier/gmd:code//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="identifier" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- not tokenized title for sorting -->
<Field name="_defaultTitle" string="{string(gmd:title/gco:CharacterString)}" store="true" index="true"/>
<xsl:for-each select="gmd:title//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="title" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:alternateTitle//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="altTitle" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue='revision']/gmd:date/gco:Date">
<Field name="revisionDate" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue='creation']/gmd:date/gco:Date">
<Field name="createDate" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue='publication']/gmd:date/gco:Date">
<Field name="publicationDate" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- fields used to search for metadata in paper or digital format -->
<xsl:for-each select="gmd:presentationForm">
<xsl:if test="contains(gmd:CI_PresentationFormCode/@codeListValue, 'Digital')">
<Field name="digital" string="true" store="true" index="true"/>
</xsl:if>
<xsl:if test="contains(gmd:CI_PresentationFormCode/@codeListValue, 'Hardcopy')">
<Field name="paper" string="true" store="true" index="true"/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:abstract//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="abstract" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="*/gmd:EX_Extent">
<xsl:apply-templates select="gmd:geographicElement/gmd:EX_GeographicBoundingBox" mode="latLon"/>
<xsl:for-each select="gmd:geographicElement/gmd:EX_GeographicDescription/gmd:geographicIdentifier/gmd:MD_Identifier/gmd:code//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="geoDescCode" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:description//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="extentDesc" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent|
gmd:temporalElement/gmd:EX_SpatialTemporalExtent/gmd:extent">
<xsl:for-each select="gml:TimePeriod/gml:beginPosition">
<Field name="tempExtentBegin" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gml:TimePeriod/gml:endPosition">
<Field name="tempExtentEnd" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gml:TimePeriod/gml:begin/gml:TimeInstant/gml:timePosition">
<Field name="tempExtentBegin" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gml:TimePeriod/gml:end/gml:TimeInstant/gml:timePosition">
<Field name="tempExtentEnd" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gml:TimeInstant/gml:timePosition">
<Field name="tempExtentBegin" string="{string(.)}" store="true" index="true"/>
<Field name="tempExtentEnd" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="*/gmd:MD_Keywords">
<xsl:for-each select="gmd:keyword//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="keyword" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:type/gmd:MD_KeywordTypeCode/@codeListValue">
<Field name="keywordType" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:organisationName//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="orgName" string="{string(.)}" store="true" index="true"/>
<Field name="_orgName" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:individualName/gco:CharacterString|
gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:individualFirstName/gco:CharacterString|
gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:individualLastName/gco:CharacterString">
<Field name="creator" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:choose>
<xsl:when test="gmd:resourceConstraints/gmd:MD_SecurityConstraints">
<Field name="secConstr" string="true" store="true" index="true"/>
</xsl:when>
<xsl:otherwise>
<Field name="secConstr" string="false" store="true" index="true"/>
</xsl:otherwise>
</xsl:choose>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:topicCategory/gmd:MD_TopicCategoryCode">
<Field name="topicCat" string="{string(.)}" store="true" index="true"/>
<Field name="subject" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:language/gco:CharacterString">
<Field name="datasetLang" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:spatialRepresentationType/gmd:MD_SpatialRepresentationTypeCode/@codeListValue">
<Field name="spatialRepresentation" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:spatialResolution/gmd:MD_Resolution">
<xsl:for-each select="gmd:equivalentScale/gmd:MD_RepresentativeFraction/gmd:denominator/gco:Integer">
<Field name="denominator" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:distance/gco:Distance">
<Field name="distanceVal" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="gmd:distance/gco:Distance/@uom">
<Field name="distanceUom" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:graphicOverview/gmd:MD_BrowseGraphic">
<xsl:variable name="fileName" select="gmd:fileName/gco:CharacterString"/>
<xsl:if test="$fileName != ''">
<xsl:variable name="fileDescr" select="gmd:fileDescription/gco:CharacterString"/>
<xsl:choose>
<xsl:when test="contains($fileName ,'://')">
<Field name="image" string="{concat('unknown|', $fileName)}" store="true" index="false"/>
</xsl:when>
<xsl:when test="string($fileDescr)='thumbnail'">
<!-- FIXME : relative path -->
<Field name="image" string="{concat($fileDescr, '|', '../../srv/eng/resources.get?uuid=', //gmd:fileIdentifier/gco:CharacterString, '&fname=', $fileName, '&access=public')}" store="true" index="false"/>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Fields use to search on Service -->
<xsl:for-each select="srv:serviceType/gco:LocalName">
<Field name="serviceType" string="{string(.)}" store="true" index="true"/>
<Field name="type" string="service-{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="srv:serviceTypeVersion/gco:CharacterString">
<Field name="serviceTypeVersion" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="//srv:SV_OperationMetadata/srv:operationName/gco:CharacterString">
<Field name="operation" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="srv:operatesOn/@uuidref">
<Field name="operatesOn" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="srv:coupledResource">
<xsl:for-each select="srv:SV_CoupledResource/srv:identifier/gco:CharacterString">
<Field name="operatesOnIdentifier" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<xsl:for-each select="srv:SV_CoupledResource/srv:operationName/gco:CharacterString">
<Field name="operatesOnName" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="//srv:SV_CouplingType/srv:code/@codeListValue">
<Field name="couplingType" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- === Distribution === -->
<xsl:for-each select="gmd:distributionInfo/gmd:MD_Distribution">
<xsl:for-each select="gmd:distributionFormat/gmd:MD_Format/gmd:name//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="format" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- index online protocol -->
<xsl:for-each select="gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:protocol//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="protocol" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- === Service stuff === -->
<!-- Service type -->
<xsl:for-each select="gmd:identificationInfo/srv:SV_ServiceIdentification/srv:serviceType/gco:LocalName|
gmd:identificationInfo/*[@gco:isoType='srv:SV_ServiceIdentification']/srv:serviceType/gco:LocalName">
<Field name="serviceType" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- Service version -->
<xsl:for-each select="gmd:identificationInfo/srv:SV_ServiceIdentification/srv:serviceTypeVersion/gco:CharacterString|
gmd:identificationInfo/*[@gco:isoType='srv:SV_ServiceIdentification']/srv:serviceTypeVersion/gco:CharacterString">
<Field name="serviceTypeVersion" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- === General stuff === -->
<xsl:choose>
<xsl:when test="gmd:hierarchyLevel">
<xsl:for-each select="gmd:hierarchyLevel/gmd:MD_ScopeCode/@codeListValue">
<Field name="type" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<Field name="type" string="dataset" store="true" index="true"/>
</xsl:otherwise>
</xsl:choose>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:hierarchyLevelName//gmd:LocalisedCharacterString[@locale=$langId]">
<Field name="levelName" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:fileIdentifier/gco:CharacterString">
<Field name="fileId" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<xsl:for-each select="gmd:parentIdentifier/gco:CharacterString">
<Field name="parentUuid" string="{string(.)}" store="true" index="true"/>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- === Reference system info === -->
<xsl:for-each select="gmd:referenceSystemInfo/gmd:MD_ReferenceSystem">
<xsl:for-each select="gmd:referenceSystemIdentifier/gmd:RS_Identifier">
<xsl:variable name="crs" select="concat(string(gmd:codeSpace/gco:CharacterString),'::',string(gmd:code/gco:CharacterString))"/>
<xsl:if test="$crs != '::'">
<Field name="crs" string="{$crs}" store="true" index="true"/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- === Free text search === -->
<Field name="any" store="false" index="true">
<xsl:attribute name="string">
<xsl:value-of select="normalize-space(//node()[@locale=$langId])"/>
<xsl:text> </xsl:text>
<xsl:for-each select="//@codeListValue">
<xsl:value-of select="concat(., ' ')"/>
</xsl:for-each>
</xsl:attribute>
</Field>
<xsl:apply-templates select="." mode="codeList"/>
</xsl:template>
<!-- ========================================================================================= -->
<!-- codelist element, indexed, not stored nor tokenized -->
<xsl:template match="*[./*/@codeListValue]" mode="codeList">
<xsl:param name="name" select="name(.)"/>
<Field name="{$name}" string="{*/@codeListValue}" store="false" index="true"/>
</xsl:template>
<!-- ========================================================================================= -->
<xsl:template match="*" mode="codeList">
<xsl:apply-templates select="*" mode="codeList"/>
</xsl:template>
</xsl:stylesheet>