forked from geonetwork/core-geonetwork
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standard / ISO19115-3 / Process / encode all keywords using anchor (g…
…eonetwork#8531) * Feat - added process encode-keyword-as-anchors to transform keywords encoded as characterstrings into anchors. * FEAT - removed xsl:message instructions used for debugging.
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/process/encode-keyword-as-anchor.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="2.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0" | ||
xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0" | ||
xmlns:lan="http://standards.iso.org/iso/19115/-3/lan/1.0" | ||
xmlns:mcc="http://standards.iso.org/iso/19115/-3/mcc/1.0" | ||
xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0" | ||
xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0" | ||
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xmlns:gn="http://www.fao.org/geonetwork" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:util="java:org.fao.geonet.util.XslUtil" | ||
exclude-result-prefixes="#all"> | ||
|
||
<!-- Convert all keywords encoded using CharacterString | ||
eg. | ||
```xml | ||
<mri:keyword> | ||
<gco:CharacterString>Algeria</gco:CharacterString> | ||
</mri:keyword> | ||
``` | ||
to Anchor if found in thesaurus. | ||
eg. | ||
```xml | ||
<mri:keyword> | ||
<gcx:Anchor xlink:href="http://www.naturalearthdata.com/ne_admin#Country/DZA">Algeria</gcx:Anchor> | ||
</mri:keyword> | ||
``` | ||
--> | ||
<xsl:output indent="yes" method="xml"/> | ||
|
||
|
||
<xsl:variable name="mainLanguage" as="xs:string?" | ||
select="mdb:MD_Metadata/mdb:defaultLocale/lan:PT_Locale/ | ||
lan:language/lan:LanguageCode/ | ||
@codeListValue[normalize-space(.) != '']"/> | ||
|
||
<xsl:template match="mri:MD_Keywords[count(mri:keyword/gco:CharacterString) > 0]"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*"/> | ||
|
||
<xsl:apply-templates mode="characterString-to-anchor" select="mri:keyword"/> | ||
|
||
<xsl:apply-templates select="mri:type|mri:thesaurusName"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
|
||
<xsl:template mode="characterString-to-anchor" | ||
match="mri:keyword"> | ||
<xsl:variable name="keywordLabel" | ||
select="gco:CharacterString"/> | ||
<xsl:variable name="thesaurusId" | ||
select="substring-after(../mri:thesaurusName/*/cit:identifier/*/mcc:code/*/text(), 'geonetwork.thesaurus.')"/> | ||
<xsl:variable name="keywordUri" | ||
select="util:getKeywordUri( | ||
$keywordLabel, | ||
$thesaurusId, | ||
$mainLanguage)"/> | ||
|
||
<xsl:choose> | ||
<xsl:when test="$keywordLabel != '' and $keywordUri"> | ||
<xsl:copy> | ||
<gcx:Anchor xlink:href="{$keywordUri}"> | ||
<xsl:value-of select="$keywordLabel"/> | ||
</gcx:Anchor> | ||
<xsl:copy-of select="lan:PT_FreeText"/> | ||
</xsl:copy> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:copy-of select="."/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
<xsl:template match="gn:*" priority="2"/> | ||
|
||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
</xsl:stylesheet> |