Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » xml formatting in eclipse 3.0
xml formatting in eclipse 3.0 [message #277200] Mon, 06 December 2004 13:06 Go to next message
Eclipse UserFriend
Hi,
In eclipse 2.x, I used classes supplied by org.apache.xml.serialize. In
3.0, this doesn;t seem to be part of the base distribution. Is there
a recommended way to do XML formatting using code which is part of the
eclipse base?

Thanks.
--Len
Re: xml formatting in eclipse 3.0 [message #277210 is a reply to message #277200] Mon, 06 December 2004 15:20 Go to previous message
Eclipse UserFriend
Hi Len,

XMLSerializer was deprecated. Now it is gone....
All Classes are part of the JDK, so there is no special need of
Eclipse-dependencies.
The following snippet is code I used to convert a Document into a String.

Document document = ...;
DOMSource domSource = new DOMSource(document);
StreamResult streamResult = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1 ");
// serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd ");
serializer.setOutputProperty(OutputKeys.INDENT,"yes");
serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4");
serializer.transform(domSource, streamResult);
String result = writer.getBuffer().toString();

Best regards,

feri
Previous Topic:Associate an editor with files with NO extension?
Next Topic:xml parsing problem on Eclipse3.0
Goto Forum:
  


Current Time: Wed Nov 05 15:03:54 EST 2025

Powered by FUDForum. Page generated in 0.23821 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top