Created
September 20, 2016 20:39
-
-
Save jindrichmynarz/dd4c458f65cd3b3bf7adefa10e9cea7c to your computer and use it in GitHub Desktop.
Summarizes hierarchical structure of an XML document
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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> | |
| <xsl:output encoding="UTF-8" indent="yes" method="xml" /> | |
| <xsl:template match="/*"> | |
| <xsl:element name="{name()}"> | |
| <xsl:call-template name="group"/> | |
| </xsl:element> | |
| </xsl:template> | |
| <xsl:template name="group"> | |
| <xsl:for-each-group select="*" group-by="name()"> | |
| <xsl:sort select="current-grouping-key()"/> | |
| <xsl:element name="{current-grouping-key()}"> | |
| <xsl:call-template name="group"/> | |
| </xsl:element> | |
| </xsl:for-each-group> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment