Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attribute xlink:role for map online resources #230

Merged
merged 1 commit into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/main/plugin/iso19139.ca.HNAP/process/onlinesrc-add.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,16 @@ Insert is made in first transferOptions found.
-->
<xsl:choose>
<xsl:when test="starts-with($protocol, 'OGC:') and $name != ''">

<xsl:variable name="resourceLang">
<xsl:choose>
<xsl:when test="ends-with($desc, 'fra')"><xsl:value-of select="'urn:xml:lang:fra-CAN'"/></xsl:when>
<xsl:otherwise><xsl:value-of select="'urn:xml:lang:eng-CAN'"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>

<gmd:onLine>
<xsl:if test="$language">
<xsl:attribute name="xlink:role" select="$language"/>
</xsl:if>
<xsl:attribute name="xlink:role" select="$resourceLang"/>

<xsl:if test="$uuidref">
<xsl:attribute name="uuidref" select="$uuidref"/>
Expand Down Expand Up @@ -258,10 +264,10 @@ Insert is made in first transferOptions found.
<xsl:variable name="nameValue"
select="substring-after(., '#')"></xsl:variable>

<xsl:message>useOnlyPTFreeText: <xsl:value-of select="$useOnlyPTFreeText" /></xsl:message>
<!--<xsl:message>useOnlyPTFreeText: <xsl:value-of select="$useOnlyPTFreeText" /></xsl:message>
<xsl:message>ML: <xsl:value-of select="$mainLang" /></xsl:message>
<xsl:message>nameLang: <xsl:value-of select="$nameLang" /></xsl:message>
<xsl:message>nameValue: <xsl:value-of select="$nameValue" /></xsl:message>
<xsl:message>nameValue: <xsl:value-of select="$nameValue" /></xsl:message>-->


<xsl:if
Expand Down Expand Up @@ -363,8 +369,17 @@ Insert is made in first transferOptions found.
<!-- ... the name is simply added in the newly
created online element. -->
<gmd:onLine>
<xsl:if test="$language">
<xsl:attribute name="xlink:role" select="$language"/>
<xsl:variable name="isMapProtocol" select="starts-with($protocol, 'ESRI REST:') or starts-with($protocol, 'OGC:')" />

<xsl:variable name="resourceLang">
<xsl:choose>
<xsl:when test="ends-with($desc, 'fra')"><xsl:value-of select="'urn:xml:lang:fra-CAN'"/></xsl:when>
<xsl:otherwise><xsl:value-of select="'urn:xml:lang:eng-CAN'"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:if test="$isMapProtocol">
<xsl:attribute name="xlink:role" select="$resourceLang"/>
</xsl:if>

<xsl:if test="$uuidref">
Expand Down Expand Up @@ -446,10 +461,10 @@ Insert is made in first transferOptions found.
<xsl:variable name="nameValue"
select="substring-after(., '#')"></xsl:variable>

<xsl:message>useOnlyPTFreeText: <xsl:value-of select="$useOnlyPTFreeText" /></xsl:message>
<!--<xsl:message>useOnlyPTFreeText: <xsl:value-of select="$useOnlyPTFreeText" /></xsl:message>
<xsl:message>ML: <xsl:value-of select="$mainLang" /></xsl:message>
<xsl:message>nameLang: <xsl:value-of select="$nameLang" /></xsl:message>
<xsl:message>nameValue: <xsl:value-of select="$nameValue" /></xsl:message>
<xsl:message>nameValue: <xsl:value-of select="$nameValue" /></xsl:message>-->


<xsl:if
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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:gco="http://www.isotc211.org/2005/gco"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:exsl="http://exslt.org/common"
xmlns:geonet="http://www.fao.org/geonetwork" exclude-result-prefixes="#all" version="2.0">

<!-- ================================================================= -->

<xsl:template match="gmd:MD_Metadata">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>


<!-- ================================================================= -->

<xsl:template match="gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[not(@xlink:role) and
(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString = 'OGC:WMS' or starts-with(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, 'ESRI REST:'))]">

<xsl:variable name="resourceLang">
<xsl:choose>
<xsl:when test="ends-with(gmd:CI_OnlineResource/gmd:description/gco:CharacterString, 'fra')"><xsl:value-of select="'urn:xml:lang:fra-CAN'"/></xsl:when>
<xsl:otherwise><xsl:value-of select="'urn:xml:lang:eng-CAN'"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:copy>
<xsl:attribute name="xlink:role"><xsl:value-of select="$resourceLang" /></xsl:attribute>
<xsl:copy-of select="@*" />

<xsl:apply-templates select="*" />
</xsl:copy>
</xsl:template>

<!-- ================================================================= -->

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<!-- ================================================================= -->

<!-- Remove geonet:* elements. -->
<xsl:template match="geonet:*" priority="2"/>
<xsl:template match="@geonet:*" priority="2"/>
</xsl:stylesheet>