• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stax-DOM-SAX comparison

 
Ranch Hand
Posts: 1907
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to develop the application which is supposed to process large XML files-50 to 100MB each file on average.Application is supposed to receive Zip file which contains multiple XML files of above size.The number of XML files in ZIP files vary from 1 to 25.
I am using Tibco BW tool(which uses DOM parser for validating and parsing).Successive operations after parsing are:
creating flat files based on soem rules.
My question is-If multiple zip files arrive which contains multiple large XML files, application consumes lot of memory and processing takes logn time.
Can using of Stax an better alternative to DOM/SAX in such cases?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An event oriented parser such as SAX or StaX will certainly take less memory and run faster than building and manipulating a DOM.

The feasibility really depends on the type of data manipulation you are doing - can you imagine doing it by hand - reading a tape which shows you one XML element at a time while you make notes on a small pad of paper? Thats SAX/Stax.

OR - would the "by hand" manipulation be more like reading a book, bouncing back and forth to the index, table of contents, and multiple chapters to assemble your output. Thats DOM.

Bill
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stax parser will be a good choice as it is a pull parser.

http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.6/tutorial/doc/SJSXP2.html

"Streaming pull parsing refers to a programming model in which a client application calls methods on an XML parsing library when it needs to interact with an XML infoset--that is, the client only gets (pulls) XML data when it explicitly asks for it. "
 
Arjun Shastry
Ranch Hand
Posts: 1907
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for help.
Another question- Is it possible to validate XML using Stax? In case of DOM, we can validate XML against XSD using validator API .Is that possible in Stax? If yes, then memory again will be a problem i think as entire file needs to be brought in memory.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest you can find the answer to the validating question in the JavaDocs for the javax.xml.stream.XMLInputFactory class.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic