Re: indent XML doc based on spaces?

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

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=""; version="1.0">
   <xsl:output method="xml"/>
   <xsl:param select="'   '" name="indent-increment"/>
   <xsl:template match="*" name="noname">
      <xsl:param select="'&#xA;'" name="indent"/>
      <xsl:value-of select="$indent"/>
      <xsl:if test="name()='xsl:template'">
         <xsl:value-of select="$indent"/>
         <xsl:copy-of select="@*"/>
            <xsl:with-param select="concat($indent, $indent-increment)" name="indent"/>
         <xsl:if test="./* ">
            <xsl:value-of select="$indent"/>
   <xsl:template match="comment()|processing-instruction()">
   <xsl:template match="text()[normalize-space(.)='']"/>



X:stylesheet {

X:output method="xml"
X:param indent-increment="'   '";

X:template noname(indent="'&#xA;'") = "*" {

 X:if "name()='xsl:template'" {

 X:copy {
    X:copy-of "@*"
         !!( indent = "concat($indent, $indent-increment)" );
    X:if "./* " { !{$indent}  }

X:template = "comment()|processing-instruction()" {

X:template ="text()[normalize-space(.)='']" {}


 XSL-List info and archive:

Current Thread