| xml formatting in eclipse 3.0 [message #277200] |
Mon, 06 December 2004 13:06  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.49865 seconds