|
24 | 24 |
|
25 | 25 | <xsl:stylesheet xmlns:gmd="http://www.isotc211.org/2005/gmd" |
26 | 26 | xmlns:gco="http://www.isotc211.org/2005/gco" |
| 27 | + xmlns:gmx="http://www.isotc211.org/2005/gmx" |
27 | 28 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
28 | 29 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
29 | 30 | xmlns:che="http://www.geocat.ch/2008/che" |
|
38 | 39 | <xsl:param name="uuid"/> |
39 | 40 | <xsl:param name="title"/> |
40 | 41 |
|
41 | | - <xsl:variable name="mainLanguage" as="xs:string?" select="util:getLanguage()"/> |
42 | 42 |
|
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)"/> |
44 | 50 |
|
45 | 51 | <xsl:variable name="allLanguages"> |
46 | 52 | <lang id="default" value="{$mainLanguage}"/> |
|
52 | 58 | <!-- Subtemplate indexing --> |
53 | 59 | <xsl:template match="/"> |
54 | 60 | <xsl:variable name="isoDocLangId" select="util:getLanguage()"></xsl:variable> |
| 61 | + |
55 | 62 | <doc> |
56 | 63 | <root><xsl:value-of select="name(*)"/></root> |
57 | 64 | <xsl:copy-of select="gn-fn-index:add-field('mainLanguage', $isoDocLangId)"/> |
|
63 | 70 | </doc> |
64 | 71 | </xsl:template> |
65 | 72 |
|
66 | | - <!--Contacts & Organisations--> |
| 73 | + <!-- Indexing Contacts & Organisations --> |
67 | 74 | <xsl:template mode="index" |
68 | 75 | match="che:CHE_CI_ResponsibleParty[count(ancestor::node()) = 1]| |
69 | 76 | *[@gco:isoType='che:CHE_CI_ResponsibleParty'][count(ancestor::node()) = 1]"> |
|
77 | 84 | <xsl:variable name="mail" |
78 | 85 | select="normalize-space(gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress[1]/gco:CharacterString)"/> |
79 | 86 | <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 ''"/> |
81 | 92 |
|
82 | 93 | <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))"/>" |
85 | 96 | <xsl:for-each select="gmd:organisationName/gmd:PT_FreeText/*/gmd:LocalisedCharacterString[. != '']"> |
86 | 97 | ,"lang<xsl:value-of select="$allLanguages/lang[ |
87 | 98 | @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))"/>" |
92 | 101 | </xsl:for-each> |
93 | 102 | }</resourceTitleObject> |
94 | 103 |
|
95 | | - |
96 | 104 | <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 | + |
105 | 114 | <xsl:call-template name="subtemplate-common-fields"/> |
106 | 115 | </xsl:template> |
107 | 116 |
|
108 | 117 |
|
| 118 | + <!-- Indexing extent descriptions --> |
109 | 119 | <xsl:template mode="index" match="gmd:EX_Extent[count(ancestor::node()) = 1]"> |
| 120 | + <xsl:param name="locale"/> |
110 | 121 | <xsl:choose> |
111 | 122 | <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 | + |
113 | 137 | </xsl:when> |
114 | 138 | <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> |
116 | 146 | </xsl:otherwise> |
117 | 147 | </xsl:choose> |
118 | 148 |
|
119 | 149 | <xsl:call-template name="subtemplate-common-fields"/> |
120 | 150 | </xsl:template> |
121 | 151 |
|
| 152 | + |
| 153 | + <!-- Indexing distribution formats --> |
122 | 154 | <xsl:template mode="index" match="gmd:MD_Format[count(ancestor::node()) = 1]"> |
123 | 155 | <xsl:variable name="title" |
124 | 156 | select="if (gmd:version/gco:CharacterString = '' or gmd:version/gco:CharacterString = '-') |
125 | 157 | then gmd:name/gco:CharacterString |
126 | 158 | 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)"/> |
132 | 159 | <resourceTitleObject type="object">{ |
133 | | - "default": "<xsl:value-of select="gn-fn-index:json-escape($title)"/>" |
| 160 | + "default": "<xsl:value-of select="util:escapeForJson($title)"/>" |
134 | 161 | }</resourceTitleObject> |
135 | 162 |
|
136 | 163 | <xsl:call-template name="subtemplate-common-fields"/> |
137 | 164 | </xsl:template> |
138 | 165 |
|
| 166 | + |
| 167 | + <!-- Indexing constraints --> |
139 | 168 | <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'], ', '), |
142 | 171 | ' ', |
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> |
144 | 190 |
|
145 | 191 | <xsl:call-template name="subtemplate-common-fields"/> |
146 | 192 | </xsl:template> |
|
0 commit comments