Package org.dom4j.io

Examples of org.dom4j.io.XMLWriter


         final String timestamp = DateUtils.format(new Date(), DateUtils.ISO8601_DATETIME_PATTERN);
         root.addAttribute(TIMESTAMP_ATTRIBUTE_LABEL, timestamp);

         // Write the updated suite
         final OutputFormat format = OutputFormat.createPrettyPrint();
         final XMLWriter writer = new XMLWriter(new FileOutputStream(file), format);
         writer.write(document);
         writer.close();
      }
      catch (Exception e)
      {
         throw new BuildException(ERROR_SAVING_REPORT, e);
      }
View Full Code Here


    private void buildSchema( ResultSet columns, InputStream schemaFile, String className, String tableName, Field[] fields ) {
        Document document = DocumentHelper.createDocument();
        Element root = document.addElement( "table" );
        root.addAttribute( "name", tableName );
        root.addAttribute( "className", className );
        XMLWriter writer;
        Element field;
        HashMap<String, Field> fieldMap = new HashMap<String, Field>();
        int i;

        for( i = 0; i < fields.length; i++ ) {
            fieldMap.put( fields[ i ].getName(), fields[ i ] );
        }

        try {
            i = 0;

            while( columns.next() ) {System.out.println( columns.getString( "COLUMN_NAME" ) );
                field = root.addElement( "field" );
                field.addAttribute( "id", Integer.toString( i++ ) );
                field.addAttribute( "name", columns.getString( "COLUMN_NAME" ) );
                field.addAttribute( "dbType", columns.getString( "DATA_TYPE" ) );
                field.addAttribute( "javaType", fieldMap.get( columns.getString( "COLUMN_NAME" ) ).getType().toString() );
               
            }

            OutputFormat format = OutputFormat.createPrettyPrint();
            writer = new XMLWriter( System.out, format );
            //writer.write( document );
        } catch( SQLException e ) {

        } catch( IOException e ) {
View Full Code Here

        OutputStream os = new ByteArrayOutputStream();
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        outformat.setEncoding( "UTF-8" ); //$NON-NLS-1$

        // Writing the XML.
        XMLWriter writer = new XMLWriter( os, outformat );
        writer.write( document );
        writer.flush();
        writer.close();

        return os.toString();
    }
View Full Code Here

        if (doc == null) {
            return "[EMPTY]";
        }

        StringWriter stringWriter = new StringWriter();
        XMLWriter xmlWriter = new XMLWriter(stringWriter, OutputFormat.createPrettyPrint());
        try {
            xmlWriter.write(doc);
            xmlWriter.close();
        } catch (IOException e) {
            throw new RuntimeException("error ", e);
        }
        return stringWriter.toString();
    }
View Full Code Here

            return;
        }

        StringWriter text = new StringWriter();
        try {
            XMLWriter writer = new XMLWriter(text, OutputFormat.createPrettyPrint());
            writer.write(document);
            writer.close();
        } catch (IOException e) {
            logger.trace("{}\n{}", caption, e);
        }

        logger.trace("{}\n{}", caption, text);
View Full Code Here

        return writer.toString();
    }

    private static String toString(Document doc) {
        StringWriter stringWriter = new StringWriter();
        XMLWriter xmlWriter = new XMLWriter(stringWriter, OutputFormat.createPrettyPrint());
        try {
            xmlWriter.write(doc);
            xmlWriter.close();
        } catch (IOException exc) {
            throw new WinRmRuntimeIOException("Cannnot convert XML to String ", exc);
        }
        return stringWriter.toString();
    }
View Full Code Here

        return e.addAttribute("mustUnderstand", "false");
    }

    public static String toString(Document doc) {
        StringWriter stringWriter = new StringWriter();
        XMLWriter xmlWriter = new XMLWriter(stringWriter, OutputFormat.createPrettyPrint());
        try {
            xmlWriter.write(doc);
            xmlWriter.close();
        } catch (IOException e) {
            throw new WinRmRuntimeIOException("Cannnot convert XML to String ", e);
        }
        return stringWriter.toString();
    }
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

            InputStream inputStream) {
        try {
            Document doc = new SAXReader().read(inputStream);
            if (DEBUG) {
                StringWriter stringWriter = new StringWriter();
                XMLWriter xmlWriter = new XMLWriter(stringWriter);
                xmlWriter.write(doc);
                xmlWriter.close();
                System.out.println("UPDATE RESPONSE: " + stringWriter.toString());
            }
            List<Element> pluginEls =  XMLUtil.selectNodes(doc, "fb-plugin-updates/plugin");
            Map<String, Plugin> map = new HashMap<String, Plugin>();
            for (Plugin p : plugins) {
View Full Code Here

    }

    private void writeXML(Writer out, Project project) throws IOException {
        Document document = endDocument(project);

        XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint());
        writer.write(document);
    }
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.