Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.OutputFormat


        TagSoupParser tsp = new TagSoupParser(is, documentURI);
        return new DefaultDOMDocument( new URI(documentURI), tsp.getDOM() );
    }

    private String serialize(DOMDocument document) throws Exception {
        OutputFormat format = new OutputFormat(document.getOriginalDocument());
        format.setLineSeparator("\n");
        format.setIndenting(true);
        format.setLineWidth(0);
        format.setPreserveSpace(true);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLSerializer serializer = new XMLSerializer(
                baos,
                format
        );
View Full Code Here


     *            document to be prettified
     * @param output
     *            stream to which output is written
     */
    protected void prettyPrint(Document document, OutputStream output) {
        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"));
View Full Code Here

        else if ( source instanceof DeleteElementType ) {
            tx.getDelete().add( source );
        }
       
        Encoder encoder = new Encoder( xmlConfiguration );
        OutputFormat of = new OutputFormat();
        of.setOmitXMLDeclaration( true );
        encoder.setOutputFormat( of );
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        encoder.encode( tx, WFS.TRANSACTION, out );
        return new String( out.toByteArray() );
View Full Code Here

        else if ( source instanceof DeleteElementType ) {
            tx.getDelete().add( source );
        }

        Encoder encoder = new Encoder( xmlConfiguration );
        OutputFormat of = new OutputFormat();
        of.setOmitXMLDeclaration( true );
        encoder.setOutputFormat( of );

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        encoder.encode( tx, WFS.TRANSACTION, out );
        return new String( out.toByteArray() );
View Full Code Here

        false);
    }
  }

  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

        false);
    }
  }

  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

        false);
    }
  }

  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) {
View Full Code Here

        return super.parseBeanDefinitions(element);
    }

    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

TOP

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

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.