Skip to content

Commit

Permalink
Passing the index into remove process xslt for iso 19139
Browse files Browse the repository at this point in the history
  • Loading branch information
wangf1122 committed Oct 12, 2023
1 parent f4b57bd commit acc3540
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:util="java:org.fao.geonet.util.XslUtil"
xmlns:uuid="java:java.util.UUID"
xmlns:gn-fn-rel="http://geonetwork-opensource.org/xsl/functions/relations"
version="2.0"
exclude-result-prefixes="#all">
Expand Down Expand Up @@ -126,8 +127,9 @@
<xsl:value-of select="concat('#', upper-case(util:twoCharLangCode($lang, 'EN')))"/>
</xsl:variable>
<xsl:variable name="url" select="gmd:linkage/gmd:URL"/>
<xsl:variable name="uid" select="uuid:randomUUID()"/>
<id>
<xsl:value-of select="$url"/>
<xsl:value-of select="$uid"/>
</id>
<title>
<xsl:apply-templates mode="get-iso19139-localized-string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Stylesheet used to remove a reference to a online resource.
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">

<xsl:param name="resourceIndex"/>
<xsl:param name="url"/>
<xsl:param name="name"/>

Expand All @@ -42,12 +43,12 @@ Stylesheet used to remove a reference to a online resource.

<!-- Remove geonet:* elements. -->
<xsl:template
match="geonet:*|gmd:onLine[normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:name/gco:CharacterString) = normalize-space($name)]"
match="geonet:*|gmd:onLine[normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:name/gco:CharacterString) = normalize-space($name)][number($resourceIndex)]"
priority="2"/>
<xsl:template
match="geonet:*|gmd:onLine[normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and count(gmd:CI_OnlineResource/gmd:name/gmd:PT_FreeText/gmd:textGroup[gmd:LocalisedCharacterString = $name]) > 0]"
match="geonet:*|gmd:onLine[normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and count(gmd:CI_OnlineResource/gmd:name/gmd:PT_FreeText/gmd:textGroup[gmd:LocalisedCharacterString = $name]) > 0][number($resourceIndex)]"
priority="2"/>
<xsl:template
match="geonet:*|gmd:onLine[normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:protocol/*) = 'WWW:DOWNLOAD-1.0-http--download']"
match="geonet:*|gmd:onLine[normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:protocol/*) = 'WWW:DOWNLOAD-1.0-http--download'][number($resourceIndex)]"
priority="2"/>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,16 @@
*
* @param {Object} onlinesrc the online resource to remove
*/
removeOnlinesrc: function (onlinesrc) {
removeOnlinesrc: function (onlinesrc, onlines) {
//Passing the index of the xml/xpath into the remove process xsl
var xslIndex = -1;
for (var i = 0; i < onlines.length; i++) {
if (onlinesrc.id === onlines[i].id) {
xslIndex = i+1;
break;
}
}

var url = onlinesrc.lUrl || onlinesrc.url;
if (
url.match(".*/api/records/' + gnCurrentEdit.uuid + '/attachments/.*") != null
Expand All @@ -724,6 +733,7 @@
this,
setParams("onlinesrc-remove", {
id: gnCurrentEdit.id,
resourceIndex: xslIndex,
url: url,
name: $filter("gnLocalized")(onlinesrc.title)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
aria-label="{{'remove' | translate}} {{resource.title | gnLocalized: lang}}"
data-ng-if="readonly !== true"
data-gn-confirm-click="{{'removeOnlinesrcConfirm' | translate:{url: resource.lUrl} }}"
data-gn-click-and-spin="onlinesrcService.removeOnlinesrc(resource)"
data-gn-click-and-spin="onlinesrcService.removeOnlinesrc(resource, relations.onlines)"
>
<i class="fa fa-times text-danger"></i>
</a>
Expand Down

0 comments on commit acc3540

Please sign in to comment.