[xsd-users] Streaming

Boris Kolpackov boris at codesynthesis.com
Tue May 15 15:10:10 EDT 2007


Hi Vincent,

Vincent Jacques <vincent at vincent-jacques.net> writes:

> I use xsd with the default xerces parser.
>
> Basicaly, my xml document will come from a std::istream and I'm testing
> with std::cin for the moment. I use the xml_schema::document::parse
> method which takes a std::istream.
>
> My problem is that I have to close the stream (with Ctrl+D under Linux)
> before any parse event is trigered.

This is most likely because the underlying parser (Xerces-C++ in this
case) tries to read a chunk of data that is bigger than your document.
As a result when the code calls read() on std::cin the implementation
blocks until one of the two things happen:

 (1) the amount of data requested is read

 (2) the stream is finished (Ctrl+D)

I did a quick test and my version of Xerces-C++ (2.7.0) asks for
49152 bytes at a time. If you are interested, the code that ties
std::istream and the Xerces-C++ stream is in
libxsd/xsd/cxx/xml/sax/std-input-source.hxx.

One way to test that streaming works on small documents is to
change the readByte implementation and always read, say, 64
bytes instead of what Xerces-C++ asks in the 'size' argument.


hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070515/7d320d40/attachment.pgp


More information about the xsd-users mailing list