Skip to content

Commit

Permalink
Standard / ISO / DCAT formatters / Better support multilingual records.
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre committed Apr 23, 2024
1 parent 304bba9 commit 56c7154
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
encoding="utf-8"
cdata-section-elements="locn:geometry dcat:bbox"/>

<xsl:param name="validation" as="xs:string" select="'false'"/>
<xsl:param name="isValidating" as="xs:boolean" select="xs:boolean($validation)"/>

<xsl:template name="create-namespaces">
<xsl:namespace name="rdf" select="'http://www.w3.org/1999/02/22-rdf-syntax-ns#'"/>
<xsl:namespace name="rdfs" select="'http://www.w3.org/2000/01/rdf-schema#'"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
xmlns:srv="http://standards.iso.org/iso/19115/-3/srv/2.1"
xmlns:gex="http://standards.iso.org/iso/19115/-3/gex/1.0"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:util="java:org.fao.geonet.util.XslUtil"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
Expand Down Expand Up @@ -51,29 +52,46 @@
<xsl:import href="dcat-core-associated.xsl"/>
<xsl:import href="dcat-core-lineage.xsl"/>

<xsl:variable name="resourcePrefix"
select="concat(util:getSettingValue('nodeUrl'), 'api/records/')"
as="xs:string"/>
<!-- GeoNetwork historical DCAT export was using a setting
select="util:getSettingValue('metadata/resourceIdentifierPrefix')"/>-->
<!-- Current record is an ISO metadata
and can be an ISO19139 record before ISO19115-3 conversion. -->
<xsl:variable name="metadata"
as="node()"
select="(/root/mdb:MD_Metadata|/mdb:MD_Metadata|/root/gmd:MD_Metadata|/gmd:MD_Metadata)"/>

<xsl:variable name="languages"
<xsl:template mode="get-language"
match="mdb:MD_Metadata"
as="node()*">
<xsl:variable name="defaultLanguage"
select="/root/mdb:MD_Metadata/mdb:defaultLocale/*"/>
select="$metadata/mdb:defaultLocale/*"/>
<xsl:for-each select="$defaultLanguage">
<xsl:variable name="iso3code"
as="xs:string?"
select="lan:language/*/@codeListValue"/>
<language id="{@id}"
iso3code="{lan:language/*/@codeListValue}"
iso2code="{util:twoCharLangCode(lan:language/*/@codeListValue)}"
iso3code="{$iso3code}"
iso2code="{util:twoCharLangCode($iso3code)}"
default=""/>
</xsl:for-each>
<xsl:for-each select="/root/mdb:MD_Metadata/mdb:otherLocale/*[@id != $defaultLanguage/@id]">
<xsl:for-each select="$metadata/mdb:otherLocale/*[not(@id = $defaultLanguage/@id)]">
<language id="{@id}"
iso3code="{lan:language/*/@codeListValue}"
iso2code="{util:twoCharLangCode(lan:language/*/@codeListValue)}"/>
</xsl:for-each>
</xsl:template>

<xsl:variable name="languages"
as="node()*">
<xsl:apply-templates mode="get-language"
select="$metadata"/>
</xsl:variable>


<xsl:variable name="resourcePrefix"
select="concat(util:getSettingValue('nodeUrl'), 'api/records/')"
as="xs:string"/>
<!-- GeoNetwork historical DCAT export was using a setting
select="util:getSettingValue('metadata/resourceIdentifierPrefix')"/>-->

<xsl:function name="gn-fn-dcat:getRecordUri" as="xs:string">
<xsl:param name="metadata" as="node()"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:util="java:org.fao.geonet.util.XslUtil"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0"
exclude-result-prefixes="#all">

<xsl:template mode="get-language"
match="gmd:MD_Metadata"
as="node()*">
<xsl:variable name="defaultLanguage"
select="$metadata/gmd:language"/>
<xsl:for-each select="$defaultLanguage">
<xsl:variable name="iso3code"
as="xs:string?"
select="*/@codeListValue"/>

<language id="{../gmd:locale/*[gmd:languageCode/*/@codeListValue = $iso3code]/@id}"
iso3code="{$iso3code}"
iso2code="{util:twoCharLangCode($iso3code)}"
default=""/>
</xsl:for-each>

<xsl:for-each select="$metadata/gmd:locale/*[not(@id = $defaultLanguage/@id)]">
<language id="{@id}"
iso3code="{gmd:languageCode/*/@codeListValue}"
iso2code="{util:twoCharLangCode(gmd:languageCode/*/@codeListValue)}"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<xsl:import href="../../../iso19115-3.2018/convert/ISO19139/fromISO19139.xsl"/>
<xsl:import href="../../../iso19115-3.2018/formatter/dcat/dcat-core.xsl"/>
<xsl:import href="../dcat/dcat-utils.xsl"/>

<xsl:template match="/">
<xsl:apply-templates mode="dcat" select="root[gmd:MD_Metadata]|/gmd:MD_Metadata"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<xsl:import href="../../../iso19115-3.2018/convert/ISO19139/fromISO19139.xsl"/>
<xsl:import href="../../../iso19115-3.2018/formatter/eu-dcat-ap-hvd/eu-dcat-ap-hvd-core.xsl"/>
<xsl:import href="../dcat/dcat-utils.xsl"/>

<xsl:template match="/">
<xsl:apply-templates mode="dcat" select="root[gmd:MD_Metadata]|/gmd:MD_Metadata"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

<xsl:import href="../../../iso19115-3.2018/convert/ISO19139/fromISO19139.xsl"/>
<xsl:import href="../../../iso19115-3.2018/formatter/eu-dcat-ap/eu-dcat-ap-core.xsl"/>
<xsl:import href="../dcat/dcat-utils.xsl"/>


<xsl:template match="/">
<xsl:apply-templates mode="dcat" select="root[gmd:MD_Metadata]|/gmd:MD_Metadata"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<xsl:import href="../../../iso19115-3.2018/convert/ISO19139/fromISO19139.xsl"/>
<xsl:import href="../../../iso19115-3.2018/formatter/eu-geodcat-ap/eu-geodcat-ap-core.xsl"/>
<xsl:import href="../dcat/dcat-utils.xsl"/>

<xsl:template match="/">
<xsl:apply-templates mode="dcat" select="root[gmd:MD_Metadata]|/gmd:MD_Metadata"/>
Expand Down

0 comments on commit 56c7154

Please sign in to comment.