Skip to content

Instantly share code, notes, and snippets.

@dennislaumen
Created September 7, 2012 07:14
Show Gist options
  • Save dennislaumen/3664040 to your computer and use it in GitHub Desktop.
Save dennislaumen/3664040 to your computer and use it in GitHub Desktop.
XSLT to order a CheckStyle XML configuration by name (for diff purposes).
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="module">
<xsl:element name="module">
<xsl:for-each select="@*">
<xsl:copy-of select="."/>
</xsl:for-each>
<xsl:apply-templates select="module|property">
<xsl:sort select="local-name()" />
<xsl:sort select="@name" />
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="property">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment