Bug 32794: (follow-up) Replace code by new function (template)

Test plan:
Same as first patch.
Bonus:
Remove protocol from $u. Set first ind1 to 7.
Put mailto in $2. Check link.
Change $2 to tel. Check link.
Change $2 to https. Check link.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c15f1d65b7)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Marcel de Rooy 2023-03-22 15:50:45 +00:00 committed by Matt Blenkinsop
parent c3bfd63b8f
commit af471e271c
4 changed files with 20 additions and 88 deletions

View file

@ -927,28 +927,11 @@
<xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
<a>
<xsl:attribute name="href">
<xsl:if test="not(contains(marc:subfield[@code='u'],'://') or contains(marc:subfield[@code='u'],'mailto:'))">
<xsl:choose>
<xsl:when test="@ind1=7">
<xsl:value-of select="marc:subfield[@code='2']"/><xsl:text>://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=0">
<xsl:text>mailto:</xsl:text>
</xsl:when>
<xsl:when test="@ind1=1">
<xsl:text>ftp://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=2">
<xsl:text>telnet://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=3">
<xsl:text>tel:</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>http://</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:call-template name="AddMissingProtocol">
<xsl:with-param name="resourceLocation" select="marc:subfield[@code='u']"/>
<xsl:with-param name="indicator1" select="@ind1"/>
<xsl:with-param name="accessMethod" select="marc:subfield[@code='2']"/>
</xsl:call-template>
<xsl:value-of select="marc:subfield[@code='u']"/>
</xsl:attribute>
<xsl:choose>

View file

@ -963,28 +963,11 @@
<xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
<a>
<xsl:attribute name="href">
<xsl:if test="not(contains(marc:subfield[@code='u'],'://') or contains(marc:subfield[@code='u'],'mailto:'))">
<xsl:choose>
<xsl:when test="@ind1=7">
<xsl:value-of select="marc:subfield[@code='2']"/><xsl:text>://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=0">
<xsl:text>mailto:</xsl:text>
</xsl:when>
<xsl:when test="@ind1=1">
<xsl:text>ftp://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=2">
<xsl:text>telnet://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=3">
<xsl:text>tel:</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>http://</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:call-template name="AddMissingProtocol">
<xsl:with-param name="resourceLocation" select="marc:subfield[@code='u']"/>
<xsl:with-param name="indicator1" select="@ind1"/>
<xsl:with-param name="accessMethod" select="marc:subfield[@code='2']"/>
</xsl:call-template>
<xsl:value-of select="marc:subfield[@code='u']"/>
</xsl:attribute>
<xsl:choose>

View file

@ -1046,28 +1046,11 @@
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:if test="not(contains(marc:subfield[@code='u'],'://') or contains(marc:subfield[@code='u'],'mailto:'))">
<xsl:choose>
<xsl:when test="@ind1=7">
<xsl:value-of select="marc:subfield[@code='2']"/><xsl:text>://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=0">
<xsl:text>mailto:</xsl:text>
</xsl:when>
<xsl:when test="@ind1=1">
<xsl:text>ftp://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=2">
<xsl:text>telnet://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=3">
<xsl:text>tel:</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>http://</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:call-template name="AddMissingProtocol">
<xsl:with-param name="resourceLocation" select="marc:subfield[@code='u']"/>
<xsl:with-param name="indicator1" select="@ind1"/>
<xsl:with-param name="accessMethod" select="marc:subfield[@code='2']"/>
</xsl:call-template>
<xsl:value-of select="marc:subfield[@code='u']"/>
</xsl:attribute>
</xsl:otherwise>

View file

@ -1176,28 +1176,11 @@
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:if test="not(contains(marc:subfield[@code='u'],'://') or contains(marc:subfield[@code='u'],'mailto:'))">
<xsl:choose>
<xsl:when test="@ind1=7">
<xsl:value-of select="marc:subfield[@code='2']"/><xsl:text>://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=0">
<xsl:text>mailto:</xsl:text>
</xsl:when>
<xsl:when test="@ind1=1">
<xsl:text>ftp://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=2">
<xsl:text>telnet://</xsl:text>
</xsl:when>
<xsl:when test="@ind1=3">
<xsl:text>tel:</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>http://</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:call-template name="AddMissingProtocol">
<xsl:with-param name="resourceLocation" select="marc:subfield[@code='u']"/>
<xsl:with-param name="indicator1" select="@ind1"/>
<xsl:with-param name="accessMethod" select="marc:subfield[@code='2']"/>
</xsl:call-template>
<xsl:value-of select="marc:subfield[@code='u']"/>
</xsl:attribute>
</xsl:otherwise>