> I would like parse a streaming XML content over a socket.
Actually, Jibx handles this just fine:
Socket s = new Socket( ... );
IBindingFactory bfact =
BindingDirectory.getFactory(Customer.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
Object obj = uctx.unmarshalDocument
(s.getInputStream( ), null);
(but it won't close the stream for you - you'll have to take care of
that).
I tried it a while ago to squeeze out a little more performance, but
ended up reverting back to reading the entire document into memory and
processing it as a string. Why? Because when there's an error in the
document (or in your binding), if you process the document directly from
the stream, there's no copy to examine to determine what went wrong.
So, if you do something like this:
try
{
Obj = uctx.unmarshallDocument( s.getInputStream( ), null );
}
catch ( JiBXException e )
{
// Would like to log the contents of the offending document
// here, but can't!
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris Chen
Sent: Saturday, March 19, 2005 5:20 PM
To: [email protected]
Subject: [jibx-users] Basic New User Questions
Hi,
I have yet to entirely look into the source code of JiBX. But I am
wondering about a few things that maybe you can quickly answer for me.
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.
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?
Secondly, will jibx be able to parse a xml fragment rather than a xml
document?
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
-------------------------------------------------------
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_ide95&alloc_id396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users