Failed attempt to use DOM 3 LS to properly fix #66563, render #68942 obsolete, and fix #70576. backportto55_86510_sync20070309 generator_utilities_97382_base graph2pre3 milestone13_root vw_datasource0313 webrefactoring_root
authorjglick@netbeans.org
Wed, 28 Feb 2007 22:38:18 +0000
changeset 260ffa4cdc54d42
parent 259 806e592efbbd
child 261 80f71e15f549
Failed attempt to use DOM 3 LS to properly fix #66563, render #68942 obsolete, and fix #70576.
Stymied by apparent lack of pretty-printing support in JDK 5's LS impl.
openide.util/src/org/openide/xml/XMLUtil.java
     1.1 --- a/openide.util/src/org/openide/xml/XMLUtil.java	Tue Feb 27 17:57:47 2007 +0000
     1.2 +++ b/openide.util/src/org/openide/xml/XMLUtil.java	Wed Feb 28 22:38:18 2007 +0000
     1.3 @@ -23,7 +23,6 @@
     1.4  import java.io.IOException;
     1.5  import java.io.OutputStream;
     1.6  import java.io.StringReader;
     1.7 -import java.lang.reflect.Method;
     1.8  import javax.xml.parsers.DocumentBuilder;
     1.9  import javax.xml.parsers.DocumentBuilderFactory;
    1.10  import javax.xml.parsers.ParserConfigurationException;
    1.11 @@ -355,7 +354,20 @@
    1.12              throw new NullPointerException("You must set an encoding; use \"UTF-8\" unless you have a good reason not to!"); // NOI18N
    1.13          }
    1.14          Document doc2 = normalize(doc);
    1.15 -        // XXX should try to use org.w3c.dom.ls.LSSerializer if it exists...
    1.16 +        // XXX the following DOM 3 LS implementation of the rest of this method works fine on JDK 6 but pretty-printing is broken on JDK 5:
    1.17 +        /*
    1.18 +        DOMImplementationLS ls = (DOMImplementationLS) doc.getImplementation().getFeature("LS", "3.0"); // NOI18N
    1.19 +        assert ls != null : "No DOM 3 LS supported in " + doc.getClass().getName();
    1.20 +        LSOutput output = ls.createLSOutput();
    1.21 +        output.setEncoding(enc);
    1.22 +        output.setByteStream(out);
    1.23 +        LSSerializer ser = ls.createLSSerializer();
    1.24 +        String fpp = "format-pretty-print"; // NOI18N
    1.25 +        if (ser.getDomConfig().canSetParameter(fpp, true)) {
    1.26 +            ser.getDomConfig().setParameter(fpp, true);
    1.27 +        }
    1.28 +        ser.write(doc2, output);
    1.29 +         */
    1.30          // XXX #66563 workaround
    1.31          ClassLoader orig = Thread.currentThread().getContextClassLoader();
    1.32          ClassLoader global = Lookup.getDefault().lookup(ClassLoader.class);