Skip to content

Instantly share code, notes, and snippets.

@matematikaadit
Last active January 15, 2020 06:59
Show Gist options
  • Save matematikaadit/9ba6d8448f7fb94d6c2c328b170da7b0 to your computer and use it in GitHub Desktop.
Save matematikaadit/9ba6d8448f7fb94d6c2c328b170da7b0 to your computer and use it in GitHub Desktop.

Command

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)

Success

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment