Skip to content

Commit

Permalink
Add missing <xsl:copy> that was causing bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwallen committed Oct 30, 2023
1 parent f4a8b82 commit af6ad78
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 83 deletions.
43 changes: 22 additions & 21 deletions schemas/iso19139/src/main/plugin/iso19139/process/onlinesrc-add.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Insert is made in first transferOptions found.
resourceIdx is the index location of the object to be removed - can be used when duplicate entries exists to ensure the correct one is removed.
-->

<xsl:param name="updateKey"/>
<xsl:param name="resourceHash"/>
<xsl:param name="resourceIdx"/>
<xsl:param name="updateKey" select="''"/>
<xsl:param name="resourceHash" select="''"/>
<xsl:param name="resourceIdx" select="''"/>

<xsl:variable name="update_flag">
<xsl:value-of select="boolean($updateKey != '' or $resourceHash != '' or $resourceIdx != '')"/>
Expand Down Expand Up @@ -151,24 +151,25 @@ Insert is made in first transferOptions found.
<xsl:template
priority="2"
match="*[$update_flag = true() and gmd:onLine]">
<xsl:for-each select="gmd:onLine">
<xsl:choose>
<xsl:when test="($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or normalize-space($updateKey) = concat(
gmd:CI_OnlineResource/gmd:linkage/gmd:URL,
gmd:CI_OnlineResource/gmd:protocol/*,
gmd:CI_OnlineResource/gmd:name/gco:CharacterString))
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<xsl:call-template name="createOnlineSrc"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

<xsl:apply-templates select="* except gmd:onLine" />

<xsl:copy>
<xsl:apply-templates select="@*|node() except gmd:onLine" />

<xsl:for-each select="gmd:onLine">
<xsl:choose>
<xsl:when test="($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or ($updateKey != '' and normalize-space($updateKey) = concat(
gmd:CI_OnlineResource/gmd:linkage/gmd:URL,
gmd:CI_OnlineResource/gmd:protocol/*,
gmd:CI_OnlineResource/gmd:name/gco:CharacterString)))
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<xsl:call-template name="createOnlineSrc"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:copy>
</xsl:template>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,35 @@ Stylesheet used to remove a reference to a online resource.
onlinesrc-remove?url=http://geonetwork.org/resource.txt&name=test
-->

<xsl:param name="resourceHash"/>
<xsl:param name="resourceIdx"/>
<xsl:param name="url"/>
<xsl:param name="name"/>
<xsl:param name="resourceHash" select="''"/>
<xsl:param name="resourceIdx" select="''"/>
<xsl:param name="url" select="''"/>
<xsl:param name="name" select="''"/>

<!-- Remove the gmd:onLine define in url parameter -->
<xsl:template
priority="2"
match="*[gmd:onLine]">
<xsl:for-each select="gmd:onLine">
<xsl:choose>

<xsl:when test="gmd:CI_OnlineResource[gmd:linkage/gmd:URL!='']
and ($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or (normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:name/gco:CharacterString) = normalize-space($name)
or 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
or normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:protocol/*) = 'WWW:DOWNLOAD-1.0-http--download')
)
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<!-- Remove the thumbnail -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:copy>
<xsl:apply-templates select="@*|node() except gmd:onLine" />

<xsl:apply-templates select="* except gmd:onLine" />
<xsl:for-each select="gmd:onLine">
<xsl:choose>
<xsl:when test="gmd:CI_OnlineResource[gmd:linkage/gmd:URL!='']
and ($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or ($url != null and (normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:name/gco:CharacterString) = normalize-space($name)
or 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
or normalize-space(gmd:CI_OnlineResource/gmd:linkage/gmd:URL) = $url and normalize-space(gmd:CI_OnlineResource/gmd:protocol/*) = 'WWW:DOWNLOAD-1.0-http--download'))
)
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<!-- Remove the thumbnail -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:copy>
</xsl:template>

<!-- Do a copy of every node and attribute -->
Expand Down
45 changes: 23 additions & 22 deletions schemas/iso19139/src/main/plugin/iso19139/process/thumbnail-add.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
resourceHash is hash value of the object to be removed which will ensure the correct value is removed. It will override the usage of updateKey
resourceIdx is the index location of the object to be removed - can be used when duplicate entries exists to ensure the correct one is removed.
-->
<xsl:param name="updateKey"/>
<xsl:param name="resourceHash"/>
<xsl:param name="resourceIdx"/>
<xsl:param name="updateKey" select="''"/>
<xsl:param name="resourceHash" select="''"/>
<xsl:param name="resourceIdx" select="''"/>

<xsl:variable name="update_flag">
<xsl:value-of select="boolean($updateKey != '' or $resourceHash != '' or $resourceIdx != '')"/>
Expand All @@ -70,25 +70,26 @@
<xsl:template
priority="2"
match="*[$update_flag = true() and gmd:graphicOverview]">
<xsl:for-each select="gmd:graphicOverview">
<xsl:choose>
<xsl:when test="($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or normalize-space($updateKey) = concat(
*/gmd:fileName/gco:CharacterString,
*/gmd:fileName/gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale = '#DE'],
*/gmd:fileDescription/gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale = '#DE'],
*/gmd:fileDescription/gco:CharacterString))
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<xsl:call-template name="fill"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

<xsl:apply-templates select="* except gmd:graphicOverview" />

<xsl:copy>
<xsl:apply-templates select="@*|node() except gmd:graphicOverview" />

<xsl:for-each select="gmd:graphicOverview">
<xsl:choose>
<xsl:when test="($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or ($updateKey != '' and normalize-space($updateKey) = concat(
*/gmd:fileName/gco:CharacterString,
*/gmd:fileName/gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale = '#DE'],
*/gmd:fileDescription/gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale = '#DE'],
*/gmd:fileDescription/gco:CharacterString)))
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<xsl:call-template name="fill"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:copy>
</xsl:template>

<!-- TMP TO REMOVE when gco:characterString is added in multilingual elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,29 @@
thumbnail-from-url-remove?thumbnail_url=http://geonetwork.org/thumbnails/image.png
-->

<xsl:param name="resourceHash"/>
<xsl:param name="resourceIdx"/>
<xsl:param name="thumbnail_url"/>
<xsl:param name="thumbnail_url" select="''"/>
<xsl:param name="resourceHash" select="''"/>
<xsl:param name="resourceIdx" select="''"/>

<!-- Remove the thumbnail define in thumbnail_url parameter -->
<xsl:template
priority="2"
priority="4"
match="*[gmd:graphicOverview]">
<xsl:for-each select="gmd:graphicOverview">
<xsl:choose>
<xsl:when test="($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or normalize-space(gmd:MD_BrowseGraphic/gmd:fileName/gco:CharacterString) = normalize-space($thumbnail_url))
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<!-- Remove the thumbnail -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

<xsl:apply-templates select="* except gmd:graphicOverview" />
<xsl:copy>
<xsl:apply-templates select="@*|node() except gmd:graphicOverview" />
<xsl:for-each select="gmd:graphicOverview">
<xsl:choose>
<xsl:when test="($resourceIdx = '' or position() = xs:integer($resourceIdx))
and ($resourceHash != '' or ($thumbnail_url != '' and normalize-space(gmd:MD_BrowseGraphic/gmd:fileName/gco:CharacterString) = normalize-space($thumbnail_url)))
and ($resourceHash = '' or util:md5Hex(exslt:node-set(.)) = $resourceHash)">
<!-- Remove the thumbnail -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:copy>
</xsl:template>

<!-- Do a copy of every node and attribute -->
Expand Down

0 comments on commit af6ad78

Please sign in to comment.