[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: indent XML doc based on spaces?

Subject: RE: indent XML doc based on spaces?
From: Joshua Allen <joshuaa@xxxxxxxxxxxxx>
Date: Sat, 7 Oct 2000 18:51:27 -0700
xsl concat indent indent increment
FYI, I used the sample supplied by Nikolai and have updated the tool with
that.  Also thanks to Eric and Martin for help in figuring out what I was
doing wrong.  So now the tool has pretty formatting, remembers last working
directory, and allows you to test XPath expression in addition to the other
new features.

Thanks!


> -----Original Message-----
> From: Nikolai Grigoriev [mailto:grig@xxxxxxxxxxx]
> Sent: Thursday, October 05, 2000 1:16 AM
> To: XSL List
> Subject: Re: indent XML doc based on spaces?
> 
> 
> Joshua,
> 
> > Has anyone built an XSLT transform that indents an XML file 
> based on spaces
> > (e.g. 3 spaces per level)?  I'm just confusing myself here. 
>  The closest I
> > have come is modifying the identity transform to be as 
> included below:
> 
> Try the following code. It differs only slightly from yours, 
> yet indents both
> starting and closing tags and has no limits on element nesting depth.
> 
> Regards,
> Nikolai
> 
> ===========================
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml"/>
> <xsl:param name="indent-increment" select="'   '" />
> 
> <xsl:template match="*">
>    <xsl:param name="indent" select="'&#xA;'"/>
> 
>    <xsl:value-of select="$indent"/>
>    <xsl:copy>
>      <xsl:copy-of select="@*" />
>      <xsl:apply-templates>
>        <xsl:with-param name="indent"
>             select="concat($indent, $indent-increment)"/>
>      </xsl:apply-templates>
>      <xsl:value-of select="$indent"/>
>    </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="comment()|processing-instruction()">
>    <xsl:copy />
> </xsl:template>
> 
> <!-- WARNING: this is dangerous. Handle with care -->
> <xsl:template match="text()[normalize-space(.)='']"/>
> 
> </xsl:stylesheet>
> 
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.