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

Wrong indentation with javax.xml.transform.Transformer

Subject: Wrong indentation with javax.xml.transform.Transformer
From: Olivier Lefevre <lefevrol@xxxxxxxxx>
Date: Tue, 20 Sep 2011 13:20:59 +0200
 Wrong indentation with javax.xml.transform.Transformer
Hi,

I am using javax.xml.transform.Transformer to pretty-print DOM
documents or fragments thereof, pulled with XPath. The relevant
code is:

  transformer.setOutputProperty(OutputKeys.INDENT, "yes");
  transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

It works fine for the root node, i.e., for a full document, but
if I try that on a node retrieved with XPath the indentation is
all messed up. For instance if I pull the location node from
this document:

<GeocodeResponse>
  <status>OK</status>
  <result>
    <geometry>
      <location>
        <lat>51.3398300</lat>
        <lng>12.3627600</lng>
      </location>
    </geometry>
  </result>
</GeocodeResponse>

using "//location" and print it I get

<location>
        <lat>51.3398300</lat>
        <lng>12.3627600</lng>
      </location>

Is this a known issue or am I doing something wrong? This is with
Java 1.6.0_27; I am unsure which exact version of the XML
libraries that implies.

Thanks,

-- O.L.

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.