Package org.dom4j.io

Examples of org.dom4j.io.XMLWriter


    }
   
    public static void saveXmlDocument(final Document xmlDocument, final String xmlFileName) {
       
        OutputFormat format = OutputFormat.createPrettyPrint();
        XMLWriter writer = null;
        try {
            writer = new XMLWriter(new FileWriter(xmlFileName), format);
            writer.write(xmlDocument);
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            if (null != writer) {
                try {
                    writer.flush();
                    writer.close();
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
View Full Code Here


         webInf.mkdirs();

         File webXml = new File(webInf, "web.xml");
         FileWriter fw = new FileWriter(webXml);
         OutputFormat format = OutputFormat.createPrettyPrint();
         XMLWriter writer = new XMLWriter(fw, format);
         writer.write(webDoc);
         writer.close();

         File jbossWebXml = new File(webInf, "jboss-web.xml");
         fw = new FileWriter(jbossWebXml);
         writer = new XMLWriter(fw, format);
         writer.write(jbossDoc);
         writer.close();

         return tmpWar.toURL();
      }
      catch (IOException e)
      {
View Full Code Here

  public static void dump(Element element) {
    try {
      // try to "pretty print" it
      OutputFormat outformat = OutputFormat.createPrettyPrint();
      XMLWriter writer = new XMLWriter( System.out, outformat );
      writer.write( element );
      writer.flush();
      System.out.println( "" );
    }
    catch( Throwable t ) {
      // otherwise, just dump it
      System.out.println( element.asXML() );
View Full Code Here

  public static void dump(Element element) {
    try {
      // try to "pretty print" it
      OutputFormat outformat = OutputFormat.createPrettyPrint();
      XMLWriter writer = new XMLWriter( System.out, outformat );
      writer.write( element );
      writer.flush();
      System.out.println( "" );
    }
    catch( Throwable t ) {
      // otherwise, just dump it
      System.out.println( element.asXML() );
View Full Code Here

    private void writeDocument(Document e) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Writer w = new PrintWriter(baos);

        try {
            XMLWriter xw = new XMLWriter(w, new OutputFormat(" ", true));
            xw.write(e);
            w.flush();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
View Full Code Here

  public static void dump(Element element) {
    try {
      // try to "pretty print" it
      OutputFormat outFormat = OutputFormat.createPrettyPrint();
      XMLWriter writer = new XMLWriter( System.out, outFormat );
      writer.write( element );
      writer.flush();
      System.out.println( "" );
    }
    catch ( Throwable t ) {
      // otherwise, just dump it
      System.out.println( element.asXML() );
View Full Code Here

            throw new IsisException(e);
        }
    }

    static String asString(final Document doc) {
        XMLWriter writer = null;
        final StringWriter sw = new StringWriter();
        try {
            // previously this code used pretty print.
            // however, that tripped up on strings with double spaces in them; the double space was normalized
            // to a single space!
            // OutputFormat outputFormat = OutputFormat.createPrettyPrint();
            // writer = new XMLWriter(sw, outputFormat);
            writer = new XMLWriter(sw);
            writer.write(doc);
            return sw.toString();
        } catch (IOException e) {
            throw new IsisException(e);
        } finally {
            if(writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
View Full Code Here

                return;
            }

            // otherwise XML
            rsp.setContentType("application/xml;charset=UTF-8");
            new XMLWriter(o).write(result);
        } finally {
            o.close();
        }
    }
View Full Code Here

  public static void dump(Element element) {
    try {
      // try to "pretty print" it
      OutputFormat outformat = OutputFormat.createPrettyPrint();
      XMLWriter writer = new XMLWriter( System.out, outformat );
      writer.write( element );
      writer.flush();
      System.out.println( "" );
    }
    catch( Throwable t ) {
      // otherwise, just dump it
      System.out.println( element.asXML() );
View Full Code Here

        OutputFormat formater = OutputFormat.createPrettyPrint();

        StringWriter out = new StringWriter();

        XMLWriter writer = new XMLWriter(out, formater);

        writer.write(doc);

        writer.close();
        text.setText(out.getBuffer().toString());
      } catch (DocumentException e) {
        textType.select(currentTextType);
        throw new RuntimeException(RedisClient.i18nFile.getText(I18nFile.XMLEXCEPTION));
      } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.dom4j.io.XMLWriter

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.