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

RE: XSLT2.0 compatibility

Subject: RE: XSLT2.0 compatibility
From: "Houghton,Andrew" <houghtoa@xxxxxxxx>
Date: Tue, 5 Sep 2006 13:59:44 -0400
concat new line
> From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx]
> Sent: 05 September, 2006 13:31
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  XSLT2.0 compatibility
>
> On 9/5/06, Lin, Jessica <jlin@xxxxxxxxxxx> wrote:
> > How should I preserve the space of the xml for human
> reading? I found
> > indent="yes" is not good enough. I have to run prttey-print
> command in
> > xml spy edit environment to see a good indent xml file.
>
> I have found Saxon 8.x.x's implementation of indent="yes" to
> be quite good.

In general it is quite good, but it doesn't give you control
over formatting.  For example, it outputs 3 spaces as an
indent.  What if I thought 2 spaces were adequate?  I cannot
control it.  What if I wanted double newlines after certain
elements?  The list goes on, but this isn't Saxon's fault.
The XSLT specification doesn't provide for this level of
control throught the use of the indent="yes" attribute.

However, that doesn't mean that you cannot control indenting
yourself.  It is a pain in the neck, but it can be done.  Use
indent="no" and output the appropriate whitespace whereever
you want it.

<xsl:variable name="indent"  select="string('&#20;&#20;')"/>
<xsl:variable name="newline" select="string('&#10;')"/>

<xsl:value-of select="concat($newline,$indent)"/>
<xsl:element name="foo">
  <xsl:value-of select="concat($newline,$newline,$indent,$indent)"/>
  <xsl:element name="bar">
    <xsl:value-of select="concat($newline,$indent,$indent)"/>
  </xsl:element>
  <xsl:value-of select="concat($newline,$newline,$indent)"/>
</xsl:element>

Should produce:

  <foo>

    <bar>
    </bar>

  </foo>

Ugly, especially for deeply nested structure, but it works.


Andy.

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-2007 All Rights Reserved.