Package com.sun.org.apache.xml.internal.serialize

Examples of com.sun.org.apache.xml.internal.serialize.OutputFormat


            }

            // Serialize the schema element.
            //
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            OutputFormat of = new OutputFormat(doc);
            XMLSerializer ser = new XMLSerializer(os, of);
            ser.serialize(schemaEl);
            os.flush();
            os.close();
            result.put(tns, os.toByteArray());
View Full Code Here


            // Element xElem = xDoc.createElement("test");
            // xElem.appendChild(xDoc.importNode(xNode, true));
            xDoc.appendChild(xDoc.importNode(xNode, true));
           
            StringWriter out = new StringWriter();
            XMLSerializer serializer = new XMLSerializer(out, new OutputFormat(xDoc));
            serializer.serialize(xDoc);
            String result = out.toString();
           
           
        SOSXMLXPath xpath = new SOSXMLXPath(new StringBuffer("<spooler><answer><ERROR code=\"4711\" text=\"ein Fehler\"/></answer></spooler>"));
View Full Code Here

        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();               
        Document document = docBuilder.newDocument();
        document.appendChild(document.importNode(node, true));
       
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, new OutputFormat(document));
        serializer.serialize(document);
        return out.toString();
    }
View Full Code Here

    final String conMethodName = conClassName + "::toXMLString";
    String strT = "";
    try {
      // get an Apache XMLSerializer configured to generate CDATA
      XMLSerializer serializer = getXMLSerializer();
      OutputFormat objOutputFormat = new OutputFormat();
      // TODO in die Optionclass
      objOutputFormat.setEncoding("iso-8859-1");
      serializer.setOutputFormat(objOutputFormat);
      StringWriter objSW = new StringWriter();
      serializer.setOutputCharStream(objSW);
      // marshal using the Apache XMLSerializer
      objM.marshal(objO, serializer.asContentHandler());
View Full Code Here

   * configure an OutputFormat to handle CDATA and indenting
   *
   * \return XMLSerializer
   */
  private XMLSerializer getXMLSerializer() {
    OutputFormat of = new OutputFormat();
    of.setCDataElements(new String[] { "^description", "^script", "^scheduler_script", "^log_mail_to", "^log_mail_cc", "^log_mail_bcc" });
    // TODO setIndenting should be an option
    of.setIndenting(true);
    XMLSerializer serializer = new XMLSerializer(of);
    return serializer;
  } // private XMLSerializer getXMLSerializer
View Full Code Here

            // not an xml document probably
            return data;
        }

        try {
            OutputFormat format = new OutputFormat(doc);
            format.setLineWidth(65);
            format.setIndenting(true);
            format.setIndent(2);
            Writer out = new StringWriter();
            XMLSerializer serializer = new XMLSerializer(out, format);
            serializer.serialize(doc);

            return out.toString();
View Full Code Here

      Element unit_price2 = document.createElement("unit_price");
      unit_price2.appendChild(document.createTextNode("34.99"));
      order_line2.appendChild(unit_price2);
      content.appendChild(order_line2);

      XMLSerializer ser = new XMLSerializer(writer, new OutputFormat("xml", "UTF-8", true));
      ser.serialize(document);

    } catch (IOException | ParserConfigurationException e) {
      e.printStackTrace();
    }
View Full Code Here

    private XMLSerializer createXMLSerializer(Node node, Format fmt) {
        if(fmt==null) {
            fmt = Format.defaultFormat;
        }
        OutputFormat format = new OutputFormat(); //node.getOwnerDocument());
        format.setIndent(fmt.indent);
        format.setOmitXMLDeclaration(!fmt.xmlDecl);
        format.setEncoding(fmt.encoding);
        return new XMLSerializer(format);
    }
View Full Code Here

  @Test
  public void testGetDocument() throws Exception {
    Document document = xmlValidation.getXMLDocument();
    if (document != null) {
      final StringWriter sWriter = new StringWriter() ;
      final OutputFormat format = new OutputFormat() ;
      format.setIndenting(true) ;
      final XMLSerializer xmlS = new XMLSerializer(sWriter, format) ;
      xmlS.asDOMSerializer() ;
      xmlS.serialize(document) ;
      log.debug(sWriter.toString()) ;
    }
View Full Code Here

        // this.connection = connection;

        // Set up the XML Serializer that will convert DIG XML Documents
        // into streams to send to the external DIG reasoner
        format = new OutputFormat();
        format.setIndent(4);
        format.setIndenting(true);
        format.setPreserveSpace(false);
        serializer = new XMLSerializer(format);
        docBuilderFactory = DocumentBuilderFactory.newInstance();
View Full Code Here

TOP

Related Classes of com.sun.org.apache.xml.internal.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.