Skip to content

Commit a51863e

Browse files
committed
realign index subtemplate with iso19139
remove unused index fields (individualFirstName and individualLastName for subtemplate), as there are no more subtemplates subsitution at import time need for any field on contact so to allow research using first or last name
1 parent 16ed8b1 commit a51863e

File tree

1 file changed

+76
-30
lines changed

1 file changed

+76
-30
lines changed

iso19139.che/src/main/plugin/iso19139.che/index-fields/index-subtemplate.xsl

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
<xsl:stylesheet xmlns:gmd="http://www.isotc211.org/2005/gmd"
2626
xmlns:gco="http://www.isotc211.org/2005/gco"
27+
xmlns:gmx="http://www.isotc211.org/2005/gmx"
2728
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2829
xmlns:xs="http://www.w3.org/2001/XMLSchema"
2930
xmlns:che="http://www.geocat.ch/2008/che"
@@ -38,9 +39,14 @@
3839
<xsl:param name="uuid"/>
3940
<xsl:param name="title"/>
4041

41-
<xsl:variable name="mainLanguage" as="xs:string?" select="util:getLanguage()"/>
4242

43-
<xsl:variable name="otherLanguages" select="distinct-values(//gmd:LocalisedCharacterString/@locale)"/>
43+
<xsl:variable name="isMultilingual" select="count(distinct-values(*//gmd:LocalisedCharacterString/@locale)) > 0"/>
44+
45+
<xsl:variable name="mainLanguage" as="xs:string?"
46+
select="util:getLanguage()"/>
47+
48+
<xsl:variable name="otherLanguages"
49+
select="distinct-values(//gmd:LocalisedCharacterString/@locale)"/>
4450

4551
<xsl:variable name="allLanguages">
4652
<lang id="default" value="{$mainLanguage}"/>
@@ -52,6 +58,7 @@
5258
<!-- Subtemplate indexing -->
5359
<xsl:template match="/">
5460
<xsl:variable name="isoDocLangId" select="util:getLanguage()"></xsl:variable>
61+
5562
<doc>
5663
<root><xsl:value-of select="name(*)"/></root>
5764
<xsl:copy-of select="gn-fn-index:add-field('mainLanguage', $isoDocLangId)"/>
@@ -63,7 +70,7 @@
6370
</doc>
6471
</xsl:template>
6572

66-
<!--Contacts & Organisations-->
73+
<!-- Indexing Contacts & Organisations -->
6774
<xsl:template mode="index"
6875
match="che:CHE_CI_ResponsibleParty[count(ancestor::node()) = 1]|
6976
*[@gco:isoType='che:CHE_CI_ResponsibleParty'][count(ancestor::node()) = 1]">
@@ -77,70 +84,109 @@
7784
<xsl:variable name="mail"
7885
select="normalize-space(gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress[1]/gco:CharacterString)"/>
7986
<xsl:variable name="contactInfo"
80-
select="if ($name != '') then $name else $mail"/>
87+
select="if ($name != '') then $name
88+
else if ($mail != '') then $mail else ''"/>
89+
<xsl:variable name="orgContactInfoSuffix"
90+
select="if ($contactInfo != '')
91+
then concat(' (', $contactInfo, ')') else ''"/>
8192

8293
<resourceTitleObject type="object">{
83-
"default": "<xsl:value-of select="gn-fn-index:json-escape(
84-
concat($org, ' (', $contactInfo, ')'))"/>"
94+
"default": "<xsl:value-of select="util:escapeForJson(
95+
concat($org, $orgContactInfoSuffix))"/>"
8596
<xsl:for-each select="gmd:organisationName/gmd:PT_FreeText/*/gmd:LocalisedCharacterString[. != '']">
8697
,"lang<xsl:value-of select="$allLanguages/lang[
8798
@id = current()/@locale/substring(., 2, 2)
88-
]/@value"/>": "<xsl:value-of select="gn-fn-index:json-escape(
89-
if ($contactInfo != '')
90-
then concat(., ' (', $contactInfo, ')')
91-
else .)"/>"
99+
]/@value"/>": "<xsl:value-of select="util:escapeForJson(
100+
concat(., $orgContactInfoSuffix))"/>"
92101
</xsl:for-each>
93102
}</resourceTitleObject>
94103

95-
96104
<any type="object">{"common": "<xsl:value-of
97-
select="gn-fn-index:json-escape(normalize-space(.))"/>"}</any>
98-
99-
<xsl:variable name="individualFirstName" select="che:individualFirstName/gco:CharacterString"/>
100-
<xsl:variable name="individualLastName" select="che:individualLastName/gco:CharacterString"/>
101-
<xsl:copy-of select="gn-fn-index:add-field('individualFirstName', $individualFirstName)"/>
102-
<xsl:copy-of select="gn-fn-index:add-field('individualLastName', $individualLastName)"/>
103-
<xsl:copy-of select="gn-fn-index:add-multilingual-field('contactOrg', gmd:organisationName, $allLanguages)"/>
104-
<xsl:copy-of select="gn-fn-index:add-multilingual-field('contactEmail', gmd:contactInfo/*/gmd:address/*/gmd:electronicMailAddress, $allLanguages)"/>
105+
select="gn-fn-index:json-escape(normalize-space(.))"/>"}</any>
106+
107+
<xsl:copy-of select="gn-fn-index:add-field('Org', $org)"/>
108+
109+
<xsl:for-each
110+
select="gmd:contactInfo/*/gmd:address/*/gmd:electronicMailAddress/gco:CharacterString">
111+
<xsl:copy-of select="gn-fn-index:add-field('email', .)"/>
112+
</xsl:for-each>
113+
105114
<xsl:call-template name="subtemplate-common-fields"/>
106115
</xsl:template>
107116

108117

118+
<!-- Indexing extent descriptions -->
109119
<xsl:template mode="index" match="gmd:EX_Extent[count(ancestor::node()) = 1]">
120+
<xsl:param name="locale"/>
110121
<xsl:choose>
111122
<xsl:when test="normalize-space(gmd:description) != ''">
112-
<xsl:copy-of select="gn-fn-index:add-multilingual-field('resourceTitle', gmd:description, $allLanguages)"/>
123+
<xsl:variable name="description"
124+
select="normalize-space((
125+
gmd:description/gco:CharacterString[. != '']
126+
|gmd:description/gmd:PT_FreeText/*/gmd:LocalisedCharacterString[. != '']
127+
)[1])"/>
128+
<resourceTitleObject type="object">{
129+
"default": "<xsl:value-of select="util:escapeForJson($description)"/>"
130+
<xsl:for-each select="gmd:description/gmd:PT_FreeText/*/gmd:LocalisedCharacterString[. != '']">
131+
,"lang<xsl:value-of select="$allLanguages/lang[
132+
@id = current()/@locale/substring(., 2, 2)
133+
]/@value"/>": "<xsl:value-of select="util:escapeForJson(.)"/>"
134+
</xsl:for-each>
135+
}</resourceTitleObject>
136+
113137
</xsl:when>
114138
<xsl:otherwise>
115-
<resourceTitle>[<xsl:value-of select="string-join(.//gco:Decimal, ', ')"/>]</resourceTitle>
139+
<xsl:variable name="name"
140+
select="concat('S:', .//gmd:southBoundLatitude/*/text(), ', W:', .//gmd:westBoundLongitude/*/text(), ', N:', .//gmd:northBoundLatitude/*/text(), ', E:',.//gmd:eastBoundLongitude/*/text())"/>
141+
142+
<resourceTitleObject type="object">{
143+
"default": "<xsl:value-of select="util:escapeForJson($name)"/>"
144+
}
145+
</resourceTitleObject>
116146
</xsl:otherwise>
117147
</xsl:choose>
118148

119149
<xsl:call-template name="subtemplate-common-fields"/>
120150
</xsl:template>
121151

152+
153+
<!-- Indexing distribution formats -->
122154
<xsl:template mode="index" match="gmd:MD_Format[count(ancestor::node()) = 1]">
123155
<xsl:variable name="title"
124156
select="if (gmd:version/gco:CharacterString = '' or gmd:version/gco:CharacterString = '-')
125157
then gmd:name/gco:CharacterString
126158
else concat(gmd:name/gco:CharacterString, ' ', gmd:version/gco:CharacterString)"/>
127-
<xsl:variable name="name" select="gmd:name/gco:CharacterString"/>
128-
<xsl:variable name="version" select="gmd:version/gco:CharacterString"/>
129-
<resourceTitle><xsl:value-of select="$title"/></resourceTitle>
130-
<xsl:copy-of select="gn-fn-index:add-field('formatName', $name)"/>
131-
<xsl:copy-of select="gn-fn-index:add-field('formatVersion', $version)"/>
132159
<resourceTitleObject type="object">{
133-
"default": "<xsl:value-of select="gn-fn-index:json-escape($title)"/>"
160+
"default": "<xsl:value-of select="util:escapeForJson($title)"/>"
134161
}</resourceTitleObject>
135162

136163
<xsl:call-template name="subtemplate-common-fields"/>
137164
</xsl:template>
138165

166+
167+
<!-- Indexing constraints -->
139168
<xsl:template mode="index" match="gmd:resourceConstraints[count(ancestor::node()) = 1]">
140-
<resourceTitle><xsl:value-of select="concat(
141-
string-join(gmd:MD_LegalConstraints/*/gmd:MD_RestrictionCode/@codeListValue[@codeListValue != 'otherConstraints'], ', '),
169+
<xsl:variable name="constraint" select="concat(
170+
string-join(gmd:MD_LegalConstraints/*/gmd:MD_RestrictionCode/@codeListValue[. != 'otherConstraints'], ', '),
142171
' ',
143-
string-join(gmd:MD_LegalConstraints/gmd:otherConstraints/*/text(), ', '))"/></resourceTitle>
172+
string-join(gmd:MD_LegalConstraints/gmd:otherConstraints/*/text(), ', '))"/>
173+
174+
<resourceTitleObject type="object">{
175+
"default": "<xsl:value-of select="util:escapeForJson($constraint)"/>"
176+
}
177+
</resourceTitleObject>
178+
179+
<xsl:call-template name="subtemplate-common-fields"/>
180+
</xsl:template>
181+
182+
183+
<!-- Indexing DQ report -->
184+
<xsl:template mode="index" match="gmd:DQ_DomainConsistency[count(ancestor::node()) = 1]">
185+
<xsl:variable name="title"
186+
select="gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:title/(gco:CharacterString|gmx:Anchor)"/>
187+
<resourceTitleObject type="object">{
188+
"default": "<xsl:value-of select="util:escapeForJson($title)"/>"
189+
}</resourceTitleObject>
144190

145191
<xsl:call-template name="subtemplate-common-fields"/>
146192
</xsl:template>

0 commit comments

Comments
 (0)