Created
December 2, 2011 21:13
-
-
Save nils-werner/1424863 to your computer and use it in GitHub Desktop.
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
<data> | |
<p>Test</p> | |
<hr /> | |
<p>After hr</p> | |
</data> |
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
<?xml version='1.0' encoding='utf-8'?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<!-- | |
Name: HTML Manipulation | |
Version: 1.0 | |
Author: Allen Chang <[email protected]> | |
URL: http://symphony21.com/downloads/xslt/file/20035/ | |
Description: | |
This is the starter utility (dubbed "The Ninja Technique") in which all awesome HTML manipulation works off. | |
Be sure to check out http://chaoticpattern.com/article/manipulating-html-in-xml/ for more info. | |
Usage: | |
1. Invoke the HTML output using: <xsl:apply-templates select="path/to/your/body/*" mode="html"/>. | |
2. Write your own overriding matching templates to manipulate the HTML. | |
--> | |
<xsl:template match="/"> | |
<xsl:apply-templates select="data/*" mode="html" /> | |
</xsl:template> | |
<xsl:template match="*" mode="html"> | |
<xsl:element name="{name()}"> | |
<xsl:apply-templates select="* | @* | text()" mode="html"/> | |
</xsl:element> | |
</xsl:template> | |
<xsl:template match="@*" mode="html"> | |
<xsl:attribute name="{name()}"> | |
<xsl:value-of select="."/> | |
</xsl:attribute> | |
</xsl:template> | |
<xsl:template match="*[preceding-sibling::hr]" mode="html" priority="1" /> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment