Skip to content

Instantly share code, notes, and snippets.

@wallymathieu
Created January 28, 2015 20:32
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 wallymathieu/e7ecb934cd2c1c6859fc to your computer and use it in GitHub Desktop.
Save wallymathieu/e7ecb934cd2c1c6859fc to your computer and use it in GitHub Desktop.
xml to html xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0" xmlns="http://www.w3.org/TR/REC-html40"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--Licensed under the new BSD License.-->
<xsl:output encoding="utf-8" indent="yes" method="html" omit-xml-declaration="yes"/>
<xsl:template match="node()">
<table>
<tr>
<th>
<xsl:value-of select="name()"/>
</th>
<!--</tr>
<tr>-->
<xsl:if test="@*">
<xsl:for-each select="@*">
<th>
<xsl:value-of select="name()"/>
</th>
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</xsl:if>
<xsl:if test="node()">
<td>
<xsl:for-each select="node()">
<xsl:apply-templates select="."/>
</xsl:for-each>
</td>
</xsl:if>
</tr>
</table>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment