Skip to content

Instantly share code, notes, and snippets.

@kanduvisla
Created May 27, 2011 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanduvisla/995258 to your computer and use it in GitHub Desktop.
Save kanduvisla/995258 to your computer and use it in GitHub Desktop.
Convert a[@target='_blank'] to a[@rel='external']
<!-- Addition to the ninja XSL utility -->
<xsl:template match="a[@target='_blank']" mode="html">
<a>
<xsl:attribute name="rel">external</xsl:attribute>
<xsl:apply-templates select="* | @*[not(name()='target')] | text()" mode="html"/>
</a>
</xsl:template>
<!-- Provide an alt-tag for images with no alt-tag: -->
<xsl:template match="img[not(@alt) or @alt = '']" mode="html">
<xsl:element name="{name()}">
<xsl:apply-templates select="* | @* | text()" mode="html"/>
<xsl:attribute name="alt">
<xsl:value-of select="concat('Image of ', $website-name)" />
</xsl:attribute>
</xsl:element>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment