Thanks for the quick reply.

Funny thing is that what I'm trying to do is parse jabber streams! :) My current implementation works with SAX. However, I was contemplating the fact where I can create a new framework that allows near-zero parsing code. So what I would do is simply create a normal Java object, and something like JiBX could parse the xml stream and fill in the object automatically for me.

I was looking at the IUnmarshallingContext, and it accepts an InputStream or Reader. My guess is that you can pass the jabber connection stream to JiBX to parse the individual xml fragments (ie. jabber:iq:agents). If JiBX doesn't close the stream, then I believe it will work out fine.

My main goal is to find a way to support near-zero coding to support any future messages coming out. near-zero coding or just creating simple model objects.

Thanks,
Chris


On Mar 19, 2005, at 3:47 PM, Chris Hill wrote:

Hi Chris,

I would like parse a streaming XML content over a socket. When I peek into the tag to determine what type of XML fragment it is, I would then pass the stream over to JiBX to map the xml data into my java object. After jibx parses the data, my stream would continue to parse the next xml fragment.

Jibx doesn't really handle streams. Perhaps there's a way to pipe a stream directly into jibx I don't know about.


I've done something similar to this, but perhaps not in the most efficient manner possible. I've got an XML stream (from a Jabber Server) And I pass the xml to a couple sax parsers, and then to jibx. The first sax parser handles the opening and closing tags of the xml stream, and then creates 'mini' xml documents based on the depth of the element in startElement(). It then passes these on to a second sax parser which checks the tag of the xml document and gets an unmarshaller out of a hashtable and turns it into a useful java object. It works very well, but as you might guess, using two SAX parsers before calling jibx means the fastest. It would probably be more efficient to use XPP3 instead to fragment the xml before passing it on to jibx.

It would be great tho, if you could just give it a stream! The problem I had with jibx and streams was that I needed finer grained control over what in the stream would become a java object, and what wasn't important to jibx.


I am wondering if this is possible with jibx? Will jibx explicitly close the stream automatically after reading or will it leave the stream unclosed?


Jibx doesn't handle streams(yet). You'll have to open the stream, read everything into a buffer, then close it and pass the contents on to jibx.

Secondly, will jibx be able to parse a xml fragment rather than a xml document?

I'm not sure I fully understand what you're asking, but I'm going to say 'yes'. You can pass it any valid xml that matches your binding via StringReader. Either an xml file with doctype declarations or just a bunch of elements.


Oh, and JIBX is great! It borders on magical in the way it 'just works'. And no I'm not paid to say that! :D
C


Thanks,
Chris



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


--
_________________________________________
<   __ __  ____                           >
<  |  |  \/ ___\  Chris Hill              >
<  |  |  / /_/  > [EMAIL PROTECTED]    >
<  |____/\___  /  http://ubergeek.tv      >
<       /_____/   The Smell of Geek!      >
<----------------------------------------->



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users



------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to