Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.OutputFormat


import org.w3c.dom.Document;


public class DOMToString {
      public static String printXML(Document doc) {
        OutputFormat  outFormat    = null;
        outFormat = new OutputFormat();
        outFormat.setEncoding("UTF-8");
        outFormat.setVersion("1.0");
        outFormat.setIndenting(true);
        outFormat.setIndent(6);
        return  printXML(doc, outFormat);    
      }
View Full Code Here


    OntoSpreadXMLState xmlSerializer = OntoSpreadStateXMLSerializer.asXML(createDemoState());
    return OntoSpreadXMLStateXMLBind.getInstance().serializeOntoSpreadXMLState(xmlSerializer);   
  }

  public void testDocumentContent() throws DocumentBuilderException{
    OutputFormat outFormat = new OutputFormat();
    outFormat.setOmitXMLDeclaration(true);   

    OntoSpreadState ontoSpreadState1 = createDemoState()

    OntoSpreadXMLState xmlSerializer = OntoSpreadStateXMLSerializer.asXML(ontoSpreadState1);
    Document document1 = createDocument(ontoSpreadState1);
View Full Code Here

        }
        return sRet;
    }

    static public String prettyPrint(Element e) throws IOException {
        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
View Full Code Here

    /**
     * @deprecated relies on XMLSerializer which is a deprecated Xerces class, use domToString instead
     */
    static public String prettyPrint(Element e) throws IOException {
        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
View Full Code Here

    /**
     * @deprecated relies on XMLSerializer which is a deprecated Xerces class, use domToString instead
     */
    static public String prettyPrint(Element e) throws IOException {
        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
View Full Code Here

    /**
     * @deprecated relies on XMLSerializer which is a deprecated Xerces class, use domToString instead
     */
    static public String prettyPrint(Element e) throws IOException {
        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
View Full Code Here

  public static String serialize(Element n) {
    String value = null;
    try
    {
      StringWriter writer = new StringWriter();
      XMLSerializer s = new XMLSerializer(writer, new OutputFormat("xml",
          "UTF-8", true));
      s.serialize(n);
      value = writer.toString();
      writer.close();
    } catch (Throwable t)
View Full Code Here

   * @param writer a java.io.Writer object.
   * @throws Exception if unable to serialize the document.
   */
  public static void serializeDoc(Document doc, Writer writer)
      throws java.lang.Exception {
    XMLSerializer s = new XMLSerializer(writer, new OutputFormat("xml",
        "UTF-8", true));
    s.serialize(doc);
  }
View Full Code Here

   * @param writer a java.io.Writer object.
   * @throws Exception if unable to serialize the DOM element.
   */
  public static void serializeElement(Element elem, Writer writer)
      throws java.lang.Exception {
    XMLSerializer s = new XMLSerializer(writer, new OutputFormat("xml",
        "UTF-8", true));
    s.serialize(elem);
  }
View Full Code Here

        try {
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
            Document xmlDoc = docBuilder.parse(new ByteArrayInputStream(xml.getBytes()));

            OutputFormat format = new OutputFormat(xmlDoc);
            format.setLineWidth(0);
            format.setIndenting(true);
            format.setIndent(2);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLSerializer serializer = new XMLSerializer(baos, format);
            serializer.serialize(xmlDoc);

            xml = baos.toString();
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.