Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.XMLSerializer


        format.setLineSeparator("\n");
        format.setIndenting(true);
        format.setLineWidth(0);
        format.setPreserveSpace(true);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLSerializer serializer = new XMLSerializer(
                baos,
                format
        );
        serializer.asDOMSerializer();
        serializer.serialize( document.getOriginalDocument() );
        return baos.toString();
    }
View Full Code Here


        OutputFormat format = new OutputFormat(document);
        // setIndenting must be first as it resets indent and line width
        format.setIndenting(true);
        format.setIndent(4);
        format.setLineWidth(200);
        XMLSerializer serializer = new XMLSerializer(output, format);
        try {
            serializer.serialize(document);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

           
      // This method of output does not output the DOCTYPE definiition
      // TODO: make a config option that toggles wether doctype is
      // written out.
      OutputFormat format = new OutputFormat();
      XMLSerializer serializer = new XMLSerializer(
          new OutputStreamWriter(out, "UTF-8"), format);

            // this method does output the DOCTYPE def
             g.stream(new OutputStreamWriter(out,"UTF-8"));
      } catch(ParserConfigurationException e) {
View Full Code Here

    }
  }

  private void printElement(Element e) throws Exception {
    OutputFormat of = new OutputFormat(e.getOwnerDocument(), "UTF-8", true);
    XMLSerializer xmls = new XMLSerializer(of);
    StringWriter sw = new StringWriter();
    xmls.setOutputCharStream(sw);
    xmls.serialize(e);
    System.err.println("element=" + sw.toString());
  }
View Full Code Here

    }
  }

  private void printElement(Element e) throws Exception {
    OutputFormat of = new OutputFormat(e.getOwnerDocument(), "UTF-8", true);
    XMLSerializer xmls = new XMLSerializer(of);
    StringWriter sw = new StringWriter();
    xmls.setOutputCharStream(sw);
    xmls.serialize(e);
    System.err.println("element=" + sw.toString());
  }
View Full Code Here

    }
  }

  private void printElement(Element e) throws Exception {
    OutputFormat of = new OutputFormat(e.getOwnerDocument(), "UTF-8", true);
    XMLSerializer xmls = new XMLSerializer(of);
    StringWriter sw = new StringWriter();
    xmls.setOutputCharStream(sw);
    xmls.serialize(e);
    System.err.println("element=" + sw.toString());
  }
View Full Code Here

    void writeComplex(OutputStream output, OutputDataType result)
            throws IOException {
        Object rawResult = result.getData().getComplexData().getData().get(0);
        if (rawResult instanceof ComplexDataEncoderDelegate) {
            ComplexDataEncoderDelegate delegate = (ComplexDataEncoderDelegate) rawResult;
            XMLSerializer xmls = new XMLSerializer(output, new OutputFormat());
            xmls.setNamespaces(true);

            try {
                delegate.encode(xmls);
            } catch (IOException e) {
                throw e;
View Full Code Here

    }

    protected void dumpXml(Element node) {
        try {
            OutputFormat format = new OutputFormat(node.getOwnerDocument(), "UTF-8", true);
            XMLSerializer serializer = new XMLSerializer(System.out, format);
            serializer.serialize(node);
        }
        catch (IOException e) {
            log.error("Failed to dump the XML node: " + e, e);
        }
View Full Code Here

        StringWriter sw = new StringWriter();
       
        // write new XML instance
        try {
            OutputFormat format = new OutputFormat(instanceS);
            XMLSerializer output = new XMLSerializer(sw, format);
            output.serialize(instanceS);
        } catch (IOException e) {
            _logger.debug("IOException: "+e.toString());
        }
       
        builtinstance = sw.toString();
View Full Code Here

     */
    public static String elementToString(Element element) throws IOException {
        StringWriter writer = new StringWriter();
        OutputFormat format = new OutputFormat();
        format.setOmitXMLDeclaration(true);
        XMLSerializer serializer = new XMLSerializer(writer, format);
        serializer.serialize(element);
        return writer.toString();
    }
View Full Code Here

TOP

Related Classes of org.apache.xml.serialize.XMLSerializer

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.