summaryrefslogtreecommitdiffstats
path: root/base/silent
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-03-26 00:48:11 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2012-03-27 16:36:22 -0500
commit2ad71e6dab29ca5ed8362fe7cb672325884aaec5 (patch)
treebb19d73925dd0a5b56ec41ff10c4d251a943fd83 /base/silent
parent78378144e71a00a67690a1f99152402c892b0103 (diff)
downloadpki-2ad71e6dab29ca5ed8362fe7cb672325884aaec5.tar.gz
pki-2ad71e6dab29ca5ed8362fe7cb672325884aaec5.tar.xz
pki-2ad71e6dab29ca5ed8362fe7cb672325884aaec5.zip
Replaced deprecated XMLSerializer.
The deprecated XMLSerializer has been replaced with LSSerializer. The new API does not provide a way to control the indentation or line width. Ticket #3
Diffstat (limited to 'base/silent')
-rw-r--r--base/silent/src/com/netscape/pkisilent/common/ParseXML.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/base/silent/src/com/netscape/pkisilent/common/ParseXML.java b/base/silent/src/com/netscape/pkisilent/common/ParseXML.java
index de1b38172..3e434498f 100644
--- a/base/silent/src/com/netscape/pkisilent/common/ParseXML.java
+++ b/base/silent/src/com/netscape/pkisilent/common/ParseXML.java
@@ -26,11 +26,13 @@ import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
public class ParseXML {
Document dom = null;
@@ -99,14 +101,17 @@ public class ParseXML {
public void prettyprintxml() {
try {
// Serialize the document
- OutputFormat format = new OutputFormat(dom);
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
- XMLSerializer serializer = new XMLSerializer(System.out, format);
+ LSSerializer writer = impl.createLSSerializer();
+ writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
+
+ LSOutput output = impl.createLSOutput();
+ output.setByteStream(System.out);
+
+ writer.write(dom, output);
- serializer.serialize(dom);
} catch (Exception e) {
}
}