users@jaxb.java.net

RE: Re: Unmarshalling via InputStream

From: Robert Lowe <rmlowe_at_rmlowe.com>
Date: Fri, 22 Aug 2003 19:36:53 +0800

Personally I think Kohsuke's explanation makes perfect sense. Without the
EOF marker, there could be some ambiguous cases. For example, consider a
character stream like this:

<root>The first document.</root>
<?some-processing-instruction?>
<!-- A comment. -->
<root>The second document.</root>

Now which document does the PI belong to? What about the comment? Without an
EOF marker there's no way to tell.

Admittedly JAXB doesn't care about PIs and comments, but a generic SAX or
DOM parser certainly would.

- Rob


-----Original Message-----
From: Malachi de Aelfweald [mailto:malachid_at_temporal-wave.com]
Sent: Friday, August 22, 2003 7:11 AM
To: users_at_jaxb.dev.java.net
Subject: RE: Re: Unmarshalling via InputStream


I'll try to follow that and come up with something, although I disagree
with the solution. In the second link, it sounds as if Kohsuke is
saying that this is the case with any XML over TCP... However, I have
another application that currently does the following (and works):

                DOMParser parser = new DOMParser();
                parser.parse(new InputSource(socket.getInputStream));
                return (new DOMBuilder()).build(parser.getDocument());

Yet, doing
        unmarshaller.unmarshal(socket.getInputStream())
or even
        unmarshaller.unmarshal(new
InputSource(socket.getInputStream()))does not work...

which means....
DOMParser can parse the data coming in, but JAXB's unmarshaller can not.
It is not an XML thing, it is a JAXB thing.

I think that is a serious bug, since anyone trying to use the
unmarshal(InputSource) or unmarshal(InputStream) will find they do not
work.
If they are going to require some custom InputStream to work, then that
class should be provided AND required by the API [ie:
unmarshal(CustomInputStream)]. It does not make sense to provide these
functions if they do not work out of the box.

Malachi

-----Original Message-----
From: Ryan Shoemaker - JavaSoft East [mailto:Ryan.Shoemaker_at_Sun.COM]
Sent: Thursday, August 21, 2003 2:36 PM
To: users_at_jaxb.dev.java.net

Malachi de Aelfweald wrote:

> I am trying to send data through a socket, using a marshaller at one
end
> and an unmarshaller at the other. To ensure that the problem was not
on
> the marshaller side (perhaps, flushing, etc), I put a filter stream on

> the unmarshaller side and saw that all the data was in fact being sent

> (including an extra blank line at the end).
>
> The unmarshaller never returns from the unmarshall call, even though
all
> the data is there. If I hard-close the stream on the sending side,
then
> it returns with the content just fine, but then the socket is hosed
for
> further communication.
>
>

A similiar question[1] has already been posted and I think Kohsuke's
reply[2]
covers your use-case as well. There's also a sample app bundled with
the
release that you may be able to leverage - look for samples/xml-channel.

Thanks,

--Ryan

[1] https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgId=10789
[2] https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgId=10835




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net