[xsde-users] Stream of Documents to Parse

Jonathan Haws Jonathan.Haws at sdl.usu.edu
Fri Aug 28 01:19:05 EDT 2015


All,

I've got a quick question.  I'm in a situation where I have a stream of 
documents to parse.  I know I can setup the parser to handle a streamed 
document, but what about multiple documents back to back?

For example, let's say I have a simple schema that defines a document 
like this:

<rootElement>
	<childElement>value</childElement>
</rootElement>

Parsing that as a stream is simple - there are examples that do that. 
However, now let's say that I have a stream coming from a socket where 
the documents can come in back to back:

<rootElement>
<childElement>value</childElement>
</rootElement>
<rootElement>
<childElement>value</childElement>
</rootElement>
<rootElement>
<childElement>value</childElement>
</rootElement>

Is there a way to handle this that is built into the library?  What I 
mean is, can I simply instantiate a document parser and continuously 
feed it data from the stream and have it return some code when the 
closing tag of the root element is seen?  Or even just allocate space 
for all root elements and children seen similar to how sequences are 
handled?  Then I can just get the number of full documents received and 
pull the data for each one?

I can work out a way to handle this outside and just stream the partials 
to the parser outside - keeping track of the start and end of a document 
myself, but if there was a way to handle this that was built into the 
tools and library that would be absolutely fantastic!

Thanks!
Jon




More information about the xsde-users mailing list