Package org.w3c.dom.ls

Examples of org.w3c.dom.ls.LSSerializer


            throw new LDPathException(msg, e);
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DOMImplementationLS lsImpl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer lsSerializer = lsImpl.createLSSerializer();
        LSOutput lsOutput = lsImpl.createLSOutput();
        lsOutput.setEncoding("UTF-8");
        lsOutput.setByteStream(baos);
        lsSerializer.write(document, lsOutput);
        String schemaStr = new String(baos.toByteArray());
        return schemaStr.getBytes();
    }
View Full Code Here


     *         instance, obtained via {@link LSSerializer#getDomConfig()}. May be null.
     */
    public static void writeNode(Node node, Writer output, Map<String, Object> serializerParams) {
        DOMImplementationLS domImplLS = getLSDOMImpl(node);
       
        LSSerializer serializer = getLSSerializer(domImplLS, serializerParams);

        LSOutput serializerOut = domImplLS.createLSOutput();
        serializerOut.setCharacterStream(output);

        serializer.write(node, serializerOut);
    }
View Full Code Here

     *         instance, obtained via {@link LSSerializer#getDomConfig()}. May be null.
     */
    public static void writeNode(Node node, OutputStream output, Map<String, Object> serializerParams) {
        DOMImplementationLS domImplLS = getLSDOMImpl(node);
       
        LSSerializer serializer = getLSSerializer(domImplLS, serializerParams);

        LSOutput serializerOut = domImplLS.createLSOutput();
        serializerOut.setByteStream(output);

        serializer.write(node, serializerOut);
    }
View Full Code Here

     *         instance, obtained via {@link LSSerializer#getDomConfig()}. May be null.
     *        
     * @return a new LSSerializer instance
     */
    public static LSSerializer getLSSerializer(DOMImplementationLS domImplLS, Map<String, Object> serializerParams) {
        LSSerializer serializer = domImplLS.createLSSerializer();
       
        serializer.setFilter(new LSSerializerFilter() {

            public short acceptNode(Node arg0) {
                return FILTER_ACCEPT;
            }

            public int getWhatToShow() {
                return SHOW_ALL;
            }
        });
       
       
        if (serializerParams != null) {
            DOMConfiguration serializerDOMConfig = serializer.getDomConfig();
            for (String key : serializerParams.keySet()) {
                serializerDOMConfig.setParameter(key, serializerParams.get(key));
            }
        }
       
View Full Code Here

    * @param doc
    * @return string
    */
   public String getStringFromDoc(org.w3c.dom.Document doc) {
      DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
      LSSerializer lsSerializer = domImplementation.createLSSerializer();
      lsSerializer.getDomConfig().setParameter("xml-declaration", false);
      //lsSerializer.getDomConfig().setParameter("xml-declaration", false);

      return lsSerializer.writeToString(doc);
   }
View Full Code Here

     * @param doc
     * @return string
     */
    public String getStringFromDoc(org.w3c.dom.Document doc) {
        DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
        LSSerializer lsSerializer = domImplementation.createLSSerializer();
        lsSerializer.getDomConfig().setParameter("xml-declaration", false);
        //lsSerializer.getDomConfig().setParameter("xml-declaration", false);

        return lsSerializer.writeToString(doc);
    }
View Full Code Here

    if (domImplementation.hasFeature("LS", "3.0")
        && domImplementation.hasFeature("Core", "2.0")) {
      DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation
          .getFeature("LS", "3.0");
      LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
      DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
      if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
        lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
        LSOutput lsOutput = domImplementationLS.createLSOutput();
        lsOutput.setEncoding("UTF-8");
        StringWriter stringWriter = new StringWriter();
        lsOutput.setCharacterStream(stringWriter);
        lsSerializer.write(doc, lsOutput);
        return stringWriter.toString();
      } else {
        throw new RuntimeException(
            "DOMConfiguration 'format-pretty-print' parameter isn't settable.");
      }
View Full Code Here

        LSInput input = domLS.createLSInput();
        input.setStringData(xml);
        Document document = lsParser.parse(input);

        LSSerializer lsSerializer = domLS.createLSSerializer();
        lsSerializer.getDomConfig().setParameter("comments", Boolean.FALSE);
        lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
        return lsSerializer.writeToString(document);
    }
View Full Code Here

            throw new LDPathException(msg, e);
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DOMImplementationLS lsImpl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer lsSerializer = lsImpl.createLSSerializer();
        LSOutput lsOutput = lsImpl.createLSOutput();
        lsOutput.setEncoding("UTF-8");
        lsOutput.setByteStream(baos);
        lsSerializer.write(document, lsOutput);
        String schemaStr = new String(baos.toByteArray());
        return schemaStr.getBytes();
    }
View Full Code Here

        .getImplementation();

    LSOutput output = impl.createLSOutput();
    output.setByteStream(byteStream);

    LSSerializer serializer = impl.createLSSerializer();
    serializer.getDomConfig().setParameter("format-pretty-print", true);
    serializer.write(document, output);
  }
View Full Code Here

TOP

Related Classes of org.w3c.dom.ls.LSSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.