  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Subject: Re: problems with "indent " | Subject: Re: problems with "indent " 2007-09-24 - By Jason Hunter
Back Per the Javadocs of getFormat():
/** * Returns the current format in use by the outputter. Note the * Format object returned is a clone of the one used internally. */
(It's a clone because formatting is not as simple as you might think.)
So you should make a Format and pass it in. I'd recommend starting with Format.getPrettyFormat(). Then adjust the line ending from \r\n to just \n.
-jh-
NP wrote: > answering to myself: > > two possibile solutions: > 1. we must get the reference to the format of the XMLOutputter, then > setting the indent line-separator parameters, and finally set the format > e.g. > > XMLOutputter serializer = new XMLOutputter(); Format > format = serializer.getFormat(); > format.setIndent(" "); > format.setLineSeparator("\n"); > serializer.setFormat(format); > > 2. else, simply, using getPrettyFormat() method: > XMLOutputter serializer = new XMLOutputter(); > serializer.setFormat(serializer.getFormat().getPrettyFormat()) > (getPrettyFormat: two space to indent, and one newline...) > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > To control your jdom-interest membership: > http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected) __ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |