File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes creating xml using sax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "creating xml using sax" Watch "creating xml using sax" New topic
Author

creating xml using sax

deep rai
Ranch Hand

Joined: Oct 04, 2007
Posts: 56
hi,

i would like to know how to create xml file using sax.

Thank you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
SAX is an API for parsing XML, not for creating it. The DOM API would be better suited. See this on how to create a XML through a DOM Document object.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Welllll thats not exactly true.

It is not commonly done but you can create a document by creating a sequence of SAX events being fed to an event handler that simply writes them to output.

Harold's chapter 8 on SAX processing gets into this to some extent.

Manipulating SAX events is the basis for "pipeline" processing of XML documents. I cite several toolkits in this survey article.

Note that the SAX approach takes MUCH less memory and CPU time than the DOM approach.

Bill
[ April 22, 2008: Message edited by: William Brogden ]
deep rai
Ranch Hand

Joined: Oct 04, 2007
Posts: 56
thankz ulf and william... just in case someone needs this in future i have attached a great linkkk below which has everything

http://xmlgraphics.apache.org/fop/0.95/embedding.html#ExampleXML2PDF
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
That page talks about creating PDFs from an XML source. How does that help with creating XML?
deep rai
Ranch Hand

Joined: Oct 04, 2007
Posts: 56
It has few examples, and in one of them it is creating xml from java objects calling sax events on the java object. its example ExampleObj2XML.java
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
Got it - you meant to link to the example below the one you actually linked to.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating xml using sax