[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Wrong indentation with javax.xml.transform.Transformer
Subject: Re: [xsl] Wrong indentation with javax.xml.transform.Transformer From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Tue, 20 Sep 2011 12:30:58 +0100 |
On 20 September 2011 12:20, Olivier Lefevre <lefevrol@xxxxxxxxx> wrote: > 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. That's correct... you will probably want to strip whitespace only text nodes from the input (which is fine provided you don't have any 'mixed content' elements). -- Andrew Welch http://andrewjwelch.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Wrong indentation with javax., Olivier Lefevre | Thread | [xsl] Re: Wrong indentation with j, Olivier Lefevre |
[xsl] Wrong indentation with javax., Olivier Lefevre | Date | [xsl] [ANN] XML Amsterdam 2011 conf, Geert Josten |
Month |