• 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

Use Stream or String as input to SAXParser

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to be able to use something other than a disk-based file as the first parameter in "parser.parse(xxxx,...)" part of the SAXParser.

I have a JDOM tree I'm trying to send to the SAXparser as a stream so the JDOM doesn't first need to be written to the disk as an XML file.

I've tried passing a String where I took the SAXParser's output and did a ".toString() on it, and I tried a ByteArrayOutputStream, but neither works.

Is it possible to send a stream of some type to the parser command using a JDOM tree as input?

I tried creating an input stream but had problems getting it to work.

Any suggestions would be greatly appreciated!

Thanks.

Mike
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, there's a class called JDOMSource that's a subclass of SAXSource. If you read its API documentation you will see an example of how to transform a JDOM document into a list of JDOM nodes. You should be able to modify that so that it transforms the JDOM document to a SAXResult that wraps the ContentHandler that you were going to use for your SAX parser. Pretty much the same as yesterday's answer.
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow, I missed that reply. Excellent.

Will update on progress!!!

Thanks again.

Mike
 
reply
    Bookmark Topic Watch Topic
  • New Topic