| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<xsl:stylesheet version="1.0" |
| 3 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
| 4 |
<xsl:output method="xml" |
| 5 |
omit-xml-declaration="no" |
| 6 |
encoding="utf-8"/> |
| 7 |
<xsl:strip-space elements="*"/> |
| 8 |
|
| 9 |
<xsl:param name="indent-increment" select="'    '"/> |
| 10 |
|
| 11 |
<xsl:template name="newline"> |
| 12 |
<xsl:text> </xsl:text> |
| 13 |
</xsl:template> |
| 14 |
|
| 15 |
<xsl:template match="comment()" mode="pretty"> |
| 16 |
<xsl:param name="indent" select="''"/> |
| 17 |
<xsl:call-template name="newline"/> |
| 18 |
<xsl:apply-templates mode="pretty"/> |
| 19 |
<xsl:comment><xsl:value-of select="."/></xsl:comment> |
| 20 |
</xsl:template> |
| 21 |
|
| 22 |
<xsl:template match="processing-instruction()" mode="pretty"> |
| 23 |
<xsl:param name="indent" select="''"/> |
| 24 |
<xsl:call-template name="newline"/> |
| 25 |
<xsl:apply-templates mode="pretty"/> |
| 26 |
<xsl:processing-instruction><xsl:value-of |
| 27 |
select="."/></xsl:processing-instruction> |
| 28 |
</xsl:template> |
| 29 |
|
| 30 |
<xsl:template match="text()" mode="pretty"> |
| 31 |
<xsl:param name="indent" select="''"/> |
| 32 |
<xsl:call-template name="newline"/> |
| 33 |
<xsl:value-of select="$indent"/> |
| 34 |
<xsl:value-of select="normalize-space(.)"/> |
| 35 |
</xsl:template> |
| 36 |
|
| 37 |
<xsl:template match="*" mode="pretty"> |
| 38 |
<xsl:param name="indent" select="''"/> |
| 39 |
<xsl:call-template name="newline"/> |
| 40 |
<xsl:value-of select="$indent"/> |
| 41 |
<xsl:choose> |
| 42 |
<xsl:when test="count(child::*) > 0"> |
| 43 |
<xsl:copy> |
| 44 |
<xsl:copy-of select="@*"/> |
| 45 |
<xsl:apply-templates select="*|node()" mode="pretty"> |
| 46 |
<xsl:with-param name="indent" |
| 47 |
select="concat ($indent, $indent-increment)"/> |
| 48 |
</xsl:apply-templates> |
| 49 |
<xsl:call-template name="newline"/> |
| 50 |
<xsl:value-of select="$indent"/> |
| 51 |
</xsl:copy> |
| 52 |
</xsl:when> |
| 53 |
<xsl:otherwise> |
| 54 |
<xsl:copy-of select="."/> |
| 55 |
</xsl:otherwise> |
| 56 |
</xsl:choose> |
| 57 |
</xsl:template> |
| 58 |
|
| 59 |
</xsl:stylesheet> |