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

Re: Wrong indentation with javax.xml.transform.Transf

Subject: Re: Wrong indentation with javax.xml.transform.Transformer
From: Philip Fearon <pgfearo@xxxxxxxxxxxxxx>
Date: Wed, 21 Sep 2011 11:33:06 +0100
Re:  Wrong indentation with  javax.xml.transform.Transf
Just an observation on pretty-printing issues:

If you, or users of your output, were using a virtual formatting
viewer or editor (which just extends the left-margin to indent) you
wouldn't care about the pretty print formatting characters. You would
simply view/edit the XML in the formatting style set in the virtual
formatter. The preference then would be to set the INDENT property of
transformer to "no", but otherwise the virtual formatter would remove
the pretty-print characters for you anyway to ensure the view (but not
the text) was properly formatted.

So far as preserving the integrity of the XML content goes: generally,
its safer to trim formatting characters than to add them. This is
because the pattern of leading whitespace characters can actually be
exploited by the trimming algorithm to ensure only pretty-print
whitespace is removed. Unless a schema can be exploited, a
pretty-printer doesn't have the equivalent information to prevent it
adding whitespace to unformatted XML where it shouldn't.

For this reason, I use code to ensure that the XSLT processor I use
never indents the XML output, even when xsl:output settings in the
XSLT request otherwise. The only thing the virtual formatter then does
to the XML is insert formatting line-feeds if required.

Phil Fearon
http://qutoric.com

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.