Skip to content

Instantly share code, notes, and snippets.

@jessgusclark
Last active December 5, 2016 16:46
Show Gist options
  • Save jessgusclark/5268778e9d10b895ab1c6f994959f6be to your computer and use it in GitHub Desktop.
Save jessgusclark/5268778e9d10b895ab1c6f994959f6be to your computer and use it in GitHub Desktop.
Second anchor replace that loops through all attributes
<xsl:template match="a[contains(@href, '.php')]">
<xsl:element name="a">
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="name(.) = 'href'">
<xsl:attribute name="href">
<xsl:value-of select ="replace(., '.php', '')"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="{name(.)}">
<xsl:value-of select ="."/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:value-of select="node()" />
</xsl:element>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment