Skip to content

Commit

Permalink
Fix keyword initialization depending on language available. geonetwor…
Browse files Browse the repository at this point in the history
…k/core-geonetwork#8268 is useful when language is not available in vocabulary. More generic keyword indexing.
  • Loading branch information
fxprunayre committed Oct 22, 2024
1 parent f220608 commit b1bc579
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,23 @@ Schematron rules can be enabled/disabled depending on the profile. See [configur

Q: Check how to enable/disable schematron rules for a profile with an example.

Validation is also taking care of checking version of a profile as profile do not always declare a new namespace for a new version.


### Indexing

TODO
For element using a vocabulary and configured in the editor configuration, indexing will automatically be done and can be used for search and aggregations.

```json
"th_high-value-dataset-category": [
{
"default": "Companies and company ownership",
"langeng": "Companies and company ownership",
"link": "http://data.europa.eu/bna/c_a9135398"
}
],
```


### Templates

Expand Down
13 changes: 10 additions & 3 deletions src/main/plugin/dcat-ap/index-fields/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<xsl:import href="common/index-utils.xsl"/>
<xsl:import href="../layout/utility-tpl-multilingual.xsl"/>
<xsl:import href="index-dcat-ap-vl.xsl"/>

<xsl:output method="xml" indent="yes"/>

Expand Down Expand Up @@ -286,10 +287,16 @@
</xsl:if>

<xsl:apply-templates mode="index-reference-date" select="."/>

<!-- Index more fields in this element -->
<xsl:apply-templates mode="index-extra-fields" select="."/>
</doc>
</xsl:for-each>
</xsl:template>

<!-- Specialized this mode to index more field for specific profiles -->
<xsl:template mode="index-extra-fields" match="*"/>

<xsl:template mode="index-constraints" match="dcat:Dataset|dcat:DataService">
<xsl:variable name="constraints">
<xsl:for-each-group select="dct:license|dcat:distribution/dcat:Distribution/dct:license"
Expand Down Expand Up @@ -347,9 +354,9 @@

<xsl:template mode="index-concept" match="dcat:Dataset|dcat:DataService">

<xsl:for-each-group select="dct:subject|dcat:theme|mdcat:statuut|mdcat:MAGDA-categorie"
<xsl:for-each-group select="*[skos:Concept and name() = $editorConfig/editor/fields/for[@use='thesaurus-list-picker']/@name]"
group-by="skos:Concept/skos:inScheme/@rdf:resource">
<xsl:variable name="thesaurusId" select="$editorConfig/editor/fields/for[@name=name(current-group()[1])]/directiveAttributes/@thesaurus"/>
<xsl:variable name="thesaurusId" select="$editorConfig/editor/fields/for[@name = name(current-group()[1])]/directiveAttributes/@thesaurus"/>
<xsl:variable name="key">
<xsl:if test="$thesaurusId != ''">
<xsl:value-of select="tokenize($thesaurusId[1], '\.')[last()]"/>
Expand Down Expand Up @@ -778,7 +785,7 @@
</xsl:variable>

<link type="object">
{
{!
"protocol": "<xsl:value-of select="$linkProtocol"/>",
"mimeType": "" ,
"url":"<xsl:value-of select="normalize-space((dcat:endpointURL|dcat:endpointDescription)[1]/@rdf:resource)"/>",
Expand Down
14 changes: 10 additions & 4 deletions src/main/plugin/dcat-ap/layout/layout-custom-fields-concepts.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@
match="*[skos:Concept and gn-fn-dcat-ap:getThesaurusConfig(name(), name(..))]">
<xsl:if test="preceding-sibling::*[1]/name() != current()/name()">
<xsl:variable name="xpath" select="concat('/', name(../..), '/', name(..), '/', name())"/>

<xsl:variable name="config" select="gn-fn-dcat-ap:getThesaurusConfig(name(), name(..), $xpath)"/>
<xsl:call-template name="thesaurus-picker-list">
<xsl:with-param name="config" select="$config"/>
<xsl:with-param name="ref" select="../gn:element/@ref"/>
<xsl:with-param name="keywords" select="../*[name() = $config/@name]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Expand All @@ -68,6 +70,7 @@
<xsl:call-template name="thesaurus-picker-list">
<xsl:with-param name="config" select="$config"/>
<xsl:with-param name="ref" select="../gn:element/@ref"/>
<xsl:with-param name="keywords" select="null"/>
</xsl:call-template>
</xsl:template>

Expand All @@ -87,23 +90,26 @@
<xsl:template name="thesaurus-picker-list">
<xsl:param name="config" as="node()"/>
<xsl:param name="ref" as="xs:string"/>
<xsl:param name="keywords" as="node()*"/>

<xsl:if test="gn-fn-dcat-ap:shouldShow($config)">
<xsl:variable name="values">
<xsl:choose>
<xsl:when test="$config/useReference = 'true' and ../*[name() = $config/@name]/@rdf:resource">
<xsl:for-each select="../*[name() = $config/@name]">
<xsl:when test="$config/useReference = 'true' and $keywords/@rdf:resource">
<xsl:for-each select="$keywords">
<xsl:variable name="v" select="replace(java:getKeywordValueByUri(@rdf:resource, $config/thesaurus, $lang), ',', ',,')"/>
<xsl:if test="string($v)">
<xsl:value-of select="$v"/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:when test="../*[name() = $config/@name]//skos:prefLabel[1]">
<xsl:value-of select="string-join(../*[name() = $config/@name]//skos:prefLabel[1]/replace(text(), ',', ',,'), ',')"/>
<xsl:when test="$keywords//(skos:prefLabel[text() != ''])[1]">
<xsl:value-of select="string-join($keywords//(skos:prefLabel[text() != ''])[1]/replace(text(), ',', ',,'), ',')"/>
</xsl:when>
</xsl:choose>
</xsl:variable>

<xsl:variable name="transformation" select="if ($config/useReference = 'true')
then 'to-dcat-ap-concept-reference'
else 'to-dcat-ap-concept'"/>
Expand Down

0 comments on commit b1bc579

Please sign in to comment.