java -cp '*' net.sf.saxon.Transform -x:org.ccil.cowan.tagsoup.Parser example.html example.xsl
(I have saxon9he.jar
and tagsoup-1.2.1.jar
in the current directory)
Output:
<!DOCTYPE HTML>
<p>Success</p>
<html> | |
<head> | |
<title>Hello</title> | |
</head> | |
<body> | |
<h1>Hello, World</h1> | |
<p>Success</p> | |
</body> | |
</html> |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
version="3.0" | |
xpath-default-namespace="http://www.w3.org/1999/xhtml" | |
exclude-result-prefixes="#all"> | |
<xsl:output method="html" html-version="5.0"/> | |
<xsl:template match="*"> | |
<xsl:element name="{local-name()}"> | |
<xsl:apply-templates select="@*"/> | |
<xsl:apply-templates select="node()"/> | |
</xsl:element> | |
</xsl:template> | |
<xsl:template match="/"> | |
<xsl:apply-templates select="//p"/> | |
</xsl:template> | |
</xsl:stylesheet> |