• 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

One large XML file is parsed by multiple modules..

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a very large xml file to be parsed.
This file needs to be parsed every hour by 6 different modules in the application.
Each module parses it differently(basically we are using SAX and the content handler for each module is different)
Is it possible to have a generic parser parse the file once and call the different content handlers depending upon some criteria instead of parsing it 6 times.
We have just started to think about this architecture and any idea is welcome.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could have a "SAX event broker" and register some listeners for it like this:
 
Siyaa Hoffman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Lasse,
This should work. Also, I was looking at the XMLFilter class.
Looks like this class works more like a pipe and events can flow from one reader to another.
It does not help much when we have more than one reader at the same level in the hierarchy.
Am I right here ?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Umm. I've never used XMLFilter and really can't say what it's meant for...
Based on the API of XMLFilterImpl, though, it looks like you could use the exact same code that I posted but only type "extends XMLFilterImpl" instead of "extends DefaultHandler".
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic