Subject: Re: indent XML doc based on spaces? From: Paul Tchistopolskii <paul@xxxxxxx> Date: Fri, 13 Oct 2000 23:18:15 -0700 |
One more thing. XSLScript is using modified version of Nicolai's intentation stylesheet. I was not happy with <element> text </element> I wanted it to be: <element> text </element> , so I added one 'if' statement to Nicolai's stylesheet and now it could be used to pretty-print xsl stylesheets. <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:param select="' '" name="indent-increment"/> <xsl:template match="*" name="noname"> <xsl:param select="'
'" name="indent"/> <xsl:value-of select="$indent"/> <xsl:if test="name()='xsl:template'"> <xsl:value-of select="$indent"/> </xsl:if> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates> <xsl:with-param select="concat($indent, $indent-increment)" name="indent"/> </xsl:apply-templates> <xsl:if test="./* "> <xsl:value-of select="$indent"/> </xsl:if> </xsl:copy> </xsl:template> <xsl:template match="comment()|processing-instruction()"> <xsl:copy/> </xsl:template> <xsl:template match="text()[normalize-space(.)='']"/> </xsl:stylesheet> Rgds.Paul. Actually: X:stylesheet { X:output method="xml" X:param indent-increment="' '"; X:template noname(indent="'
'") = "*" { !{$indent} X:if "name()='xsl:template'" { !{$indent} } X:copy { X:copy-of "@*" !!( indent = "concat($indent, $indent-increment)" ); X:if "./* " { !{$indent} } } } X:template = "comment()|processing-instruction()" { X:copy; } X:template ="text()[normalize-space(.)='']" {} } XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: indent XML doc based on spaces?, Joshua Allen | Thread | re: Xalan & SAX parsers, Kevin Byrne |
[ANN] XSLScript v 0.7, Paul Tchistopolskii | Date | Formatting Elements, Dave Gomboc |
Month |