Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.OutputFormat


   * return XML String
   */
  public String xmlElementToString(Element element) throws Exception {
    try {
      StringWriter out = new StringWriter();
      XMLSerializer serializer = new XMLSerializer(out, new OutputFormat());
      serializer.serialize(element);
      return out.toString();
    }
    catch (Exception e) {
      throw new Exception("error occurred transforming document: " + e.getMessage());
View Full Code Here


        addNode(tempDocument, tempRootElement, tempRootNode);
        tempDocument.appendChild(tempRootElement);
       
        // write the XML Document
        File tempFile = new File(inFileName);
        OutputFormat    format  = new OutputFormat( tempDocument );   //Serialize DOM
        format.setIndenting(true);
        format.setLineSeparator("\n");
        FileWriter  fout = new FileWriter(tempFile);        //Writer will be a String
        XMLSerializer    serial = new XMLSerializer( fout, format );
        serial.asDOMSerializer();                            // As a DOM Serializer
        serial.serialize( tempDocument.getDocumentElement() );
        fout.close();
View Full Code Here

        addNode(tempDocument, tempRootElement, tempRootNode);
        tempDocument.appendChild(tempRootElement);
       
        // write the XML Document
        File tempFile = new File(inFileName);
        OutputFormat    format  = new OutputFormat( tempDocument );   //Serialize DOM
        format.setIndenting(true);
        format.setLineSeparator("\n");
        FileWriter  fout = new FileWriter(tempFile);        //Writer will be a String
        XMLSerializer    serial = new XMLSerializer( fout, format );
        serial.asDOMSerializer();                            // As a DOM Serializer
        serial.serialize( tempDocument.getDocumentElement() );
        fout.close();
View Full Code Here

        addNode(tempDocument, tempRootElement, tempRootNode);
        tempDocument.appendChild(tempRootElement);
       
        // write the XML Document
        File tempFile = new File(inFileName);
        OutputFormat    format  = new OutputFormat( tempDocument );   //Serialize DOM
        format.setIndenting(true);
        format.setLineSeparator("\n");
        FileWriter  fout = new FileWriter(tempFile);        //Writer will be a String
        XMLSerializer    serial = new XMLSerializer( fout, format );
        serial.asDOMSerializer();                            // As a DOM Serializer
        serial.serialize( tempDocument.getDocumentElement() );
        fout.close();
View Full Code Here

            OutputStream out = outputContext.getOutputStream();
            if (out != null && exists()) {
                if (isMultiple()) {
                    Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
                    doc.appendChild(getProperty(JCR_VALUES).toXml(doc));
                    OutputFormat format = new OutputFormat("xml", "UTF-8", false);
                    XMLSerializer serializer = new XMLSerializer(out, format);
                    serializer.setNamespaces(true);
                    serializer.asDOMSerializer().serialize(doc);
                } else {
                    in = ((Property)item).getStream();
View Full Code Here

            e.printStackTrace();
        }

        Document     document   = parser.getDocument(); //Our Grammar

        OutputFormat    format  = new OutputFormat( document );
        java.io.StringWriter outWriter = new java.io.StringWriter();
        XMLSerializer    serial = new XMLSerializer( outWriter,format);

        TraverseSchema tst = null;
        try {
View Full Code Here

            generateXML();
            log(xmlSchema);
            xmlSerializer = new XMLSerializer(
                    new PrintWriter(
                    new FileOutputStream(xmlSchema)),
                    new OutputFormat(Method.XML, null, true));
            xmlSerializer.serialize(doc);
        }
        catch (Exception e)
        {
            throw new BuildException(e);
View Full Code Here

   
    writeInitialRoutes(xmlConfig);
    writeSolutions(xmlConfig);
   
   
    OutputFormat format = new OutputFormat();
    format.setIndenting(true);
    format.setIndent(5);
   
    try {
      Document document = xmlConfig.createDoc();
     
      Element element = document.getDocumentElement();
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    handler.setOutputCharStream(out);
    handler.startDocument();
    OutputFormat format = new OutputFormat();
    format.setIndenting(true);
    handler.setOutputFormat(format);
  }
View Full Code Here

            new File("te-report"), costModel, new Date(), options.getWorstOffenderCount(), cfg);
        break;
      case xml:
        XMLSerializer xmlSerializer = new XMLSerializer();
        xmlSerializer.setOutputByteStream(out);
        OutputFormat format = new OutputFormat();
        format.setIndenting(true);
        xmlSerializer.setOutputFormat(format);
        report = new XMLReportGenerator(xmlSerializer, costModel, options);
        break;
      case about:
        reportModel.setMessageBundle(bundleModel);
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.