Last active
December 5, 2016 16:46
-
-
Save jessgusclark/5268778e9d10b895ab1c6f994959f6be to your computer and use it in GitHub Desktop.
Second anchor replace that loops through all attributes
This file contains hidden or 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
<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