Skip to content

Instantly share code, notes, and snippets.

@abdelazer
Created August 10, 2011 20:23
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 abdelazer/1138129 to your computer and use it in GitHub Desktop.
Save abdelazer/1138129 to your computer and use it in GitHub Desktop.
Transforming Namespaced XHTML with XSLT
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:x="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="x"
version="1.0">
<!-- By default, copy everything unless we have a rule otherwise -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Do something with `div` elements in the XHTML namespace -->
<xsl:template match="x:div">
<!-- Warning: An XHTML pony is quite powerful -->
<pony>
<xsl:apply-templates match="@*|node()"/>
</pony>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment