Save This Page
Home » iText-src-2.1.3 » com.lowagie » text » xml » [javadoc | source]
com.lowagie.text.xml
public class: XmlWriter [javadoc | source]
java.lang.Object
   com.lowagie.text.DocWriter
      com.lowagie.text.xml.XmlWriter

All Implemented Interfaces:
    DocListener

A DocWriter class for XML (Remark: this class is not finished yet!).

An XmlWriter can be added as a DocListener to a certain Document by getting an instance. Every Element added to the original Document will be written to the OutputStream of this XmlWriter.

Example:

// creation of the document with a certain size and certain margins
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try {
// this will write XML to the Standard OutputStream
XmlWriter.getInstance(document, System.out);
// this will write XML to a file called text.html
XmlWriter.getInstance(document, new FileOutputStream("text.xml"));
// this will write XML to for instance the OutputStream of a HttpServletResponse-object
XmlWriter.getInstance(document, response.getOutputStream());
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
// this will close the document and all the OutputStreams listening to it
document.close();
Field Summary
public static final  byte[] PROLOG    This is the first line of the XML page. 
public static final  byte[] DOCTYPE    This is the reference to the DTD. 
public static final  byte[] DTD    This is the place where the DTD is located. 
Fields inherited from com.lowagie.text.DocWriter:
NEWLINE,  TAB,  LT,  SPACE,  EQUALS,  QUOTE,  GT,  FORWARD,  pageSize,  document,  os,  open,  pause,  closeStream
Constructor:
 protected XmlWriter(Document doc,
    OutputStream os) 
    Constructs an XmlWriter.
    Parameters:
    doc - The Document that has to be written as XML
    os - The OutputStream the writer has to write to.
 protected XmlWriter(Document doc,
    OutputStream os,
    String dtd) 
    Constructs an XmlWriter.
    Parameters:
    doc - The Document that has to be written as XML
    os - The OutputStream the writer has to write to.
    dtd - The DTD to use
Method from com.lowagie.text.xml.XmlWriter Summary:
add,   addTabs,   close,   encode,   getInstance,   getInstance,   newPage,   open
Methods from com.lowagie.text.DocWriter:
add,   addTabs,   close,   flush,   getISOBytes,   isCloseStream,   isPaused,   newPage,   open,   pause,   resetFooter,   resetHeader,   resetPageCount,   resume,   setCloseStream,   setFooter,   setHeader,   setMarginMirroring,   setMargins,   setPageCount,   setPageSize,   write,   write,   writeEnd,   writeEnd,   writeMarkupAttributes,   writeStart
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.xml.XmlWriter Detail:
 public boolean add(Element element) throws DocumentException 
    Signals that an Element was added to the Document.
 static final  void addTabs(StringBuffer buf,
    int indent) 
    Adds a number of tabs to a StringBuffer.
 public  void close() 
    Signals that the Document was closed and that no other Elements will be added.
 static final String encode(String string,
    int indent) 
    Encodes a String.
 public static XmlWriter getInstance(Document document,
    OutputStream os) 
    Gets an instance of the XmlWriter.
 public static XmlWriter getInstance(Document document,
    OutputStream os,
    String dtd) 
    Gets an instance of the XmlWriter.
 public boolean newPage() throws DocumentException 
    Signals that an new page has to be LTed.
 public  void open() 
    Signals that the Document has been opened and that Elements can be added.