Class XMLWriter

java.lang.Object
de.hybris.bootstrap.xml.XMLWriter

public class XMLWriter extends Object
XML document writer based upon a XMLTagWriter tree.

Use like this:

        XMLWriter wr = new XMLWriter(
                new FileWriter( "test.xml" ),
                new MyRootTagWriter()
        );
        // optionally define the DTD
        wr.setDtd(
                new String[]{
                        "faces-config" // name
                        "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN", // public
                        "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"  // system
        }
        );
        // optionally set encoding
        wr.setEncoding("UTF-8");

        // write
        try
    {
                wr.write( new MyRootDataObject() );
    }
        catch( XMLWriteException e )
    {
                // report some error
    }
        finally
    {
                try{ wr.close() } catch( IOException e ){}
    }
 
  • Constructor Details

    • XMLWriter

      public XMLWriter(Writer wr, XMLTagWriter root)
      Creates a new xml writer which wraps a exiting Writer.
      Parameters:
      wr - the underlying writer
      root - the root tag writer, must contain all sub tag writers of the document
    • XMLWriter

      public XMLWriter(OutputStream os, XMLTagWriter root)
      Creates a new xml writer which wraps a exiting OutputStream.
      Parameters:
      os - the underlying output stream
      root - the root tag writer, must contain all sub tag writers of the document
  • Method Details