Skip to content

Commit

Permalink
Indexing / DCAT multilingual support (#8377)
Browse files Browse the repository at this point in the history
* Indexing / DCAT multilingual support

* Use 3 letter code for field ID like in ISO
* Fix position to properly index a set of multilingual elements 

```xml
<dct:title xml:lang="nl">NL</dct:title>
<dct:title xml:lang="en">EN</dct:title>
```


Related to metadata101/dcat-ap#5

* Update web/src/main/webapp/xslt/common/index-utils.xsl

Co-authored-by: Jose García <[email protected]>

---------

Co-authored-by: Jose García <[email protected]>
  • Loading branch information
fxprunayre and josegar74 committed Sep 19, 2024
1 parent e77f9d6 commit 1a780ac
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions web/src/main/webapp/xslt/common/index-utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -244,24 +244,30 @@

<!--<xsl:message>gn-fn-index:add-field <xsl:value-of select="$fieldName"/></xsl:message>
<xsl:message>gn-fn-index:add-field elements <xsl:copy-of select="$elements"/></xsl:message>
<xsl:message>gn-fn-index:add-field languages <xsl:copy-of select="$languages"/></xsl:message>-->
<xsl:message>gn-fn-index:add-field languages <xsl:copy-of select="$languages"/></xsl:message>
<xsl:message>gn-fn-index:add-field mainLanguage <xsl:copy-of select="$mainLanguage"/></xsl:message>-->

<xsl:variable name="isArray"
select="count($elements[not(@xml:lang)]) > 1"/>
<xsl:for-each select="$elements">


<!-- Select the items to be processed depending on whether they are ISO multilingual or not ISO, but multilingual eg. DC or DCAT -->
<xsl:for-each select="if($languages and count($elements//(*:CharacterString|*:Anchor|*:LocalisedCharacterString)) = 0 ) then $elements[1] else $elements">
<xsl:variable name="element" select="."/>
<xsl:variable name="textObject" as="node()*">
<xsl:choose>
<!-- Not ISO but multilingual eg. DC or DCAT -->
<xsl:when test="$languages and count($element//(*:CharacterString|*:Anchor|*:LocalisedCharacterString)) = 0">
<xsl:if test="position() = 1">
<value><xsl:value-of select="concat($doubleQuote, 'default', $doubleQuote, ':',
$doubleQuote, util:escapeForJson(.), $doubleQuote)"/></value>
<xsl:for-each select="$elements">
<value><xsl:value-of select="concat($doubleQuote, 'lang', @xml:lang, $doubleQuote, ':',
<xsl:variable name="elementLangAttribute"
select="@xml:lang"/>
<xsl:variable name="elementLangCode"
select="$languages/lang[@value = $elementLangAttribute]/@code"/>
<value><xsl:value-of select="concat($doubleQuote, 'lang', $elementLangCode, $doubleQuote, ':',
$doubleQuote, util:escapeForJson(.), $doubleQuote)"/></value>
</xsl:for-each>
</xsl:if>
</xsl:when>
<xsl:when test="$languages">
<!-- The default language -->
Expand Down Expand Up @@ -707,10 +713,10 @@
<xsl:function name="gn-fn-index:json-escape" as="xs:string?">
<!-- This function is deprecated. Please update your code to define the following namespace:
xmlns:util="java:org.fao.geonet.util.XslUtil"
and use util:escapeForJson function
and use util:escapeForJson function
-->

<xsl:param name="v" as="xs:string?" />
<xsl:choose>
<xsl:when test="normalize-space($v) = ''"></xsl:when>
Expand Down

0 comments on commit 1a780ac

Please sign in to comment.