Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay Framework 2.0 BodyParser - push parsing XML streams
    primarykey
    data
    text
    <p>I feel rather out of my depth asking this question, since despite reading the <a href="https://github.com/playframework/Play20/wiki/Iteratees" rel="nofollow noreferrer">official docs</a> and the resources linked in these questions:</p> <p><a href="https://stackoverflow.com/questions/9858095/how-to-understand-iteratee-in-play2">How to understand `Iteratee` in play2?</a></p> <p><a href="https://stackoverflow.com/questions/10177666/cant-understand-iteratee-enumerator-enumeratee-in-play-2-0">Can&#39;t understand Iteratee, Enumerator, Enumeratee in Play 2.0</a></p> <p>... I'm still pretty hazy about iteratees, enumerators, and Play 2.0's reactive model in general. But anyway, I'd like to set up a web service that allows me to upload large XML (>100MB) files, pick out certain specific (non-interleaved) NodeSeqs, process them, and stream the results back to the client.</p> <p>I figure the first thing I need to do is write a BodyParser that takes chunks of bytes, feeds them to an XML parser, and emits a stream of the NodeSeqs I want, say <code>&lt;doc&gt;...&lt;/doc&gt;</code>, in a lazy manner.</p> <p>Could anyone offer any guidance and/or examples illustrating how this might be accomplished?</p> <p>Update: More background :-</p> <p>My XML is actually a Solr <code>add</code> document, so it looks like:</p> <pre><code>&lt;add&gt; &lt;doc&gt; &lt;field name="name"&gt;Some Entity&lt;/field&gt; &lt;field name="details"&gt;Blah blah...&lt;/field&gt; ... &lt;/doc&gt; ... &lt;/add&gt; </code></pre> <p>I want to process each <code>&lt;doc&gt;</code> in a streaming manner, so my parser would obviously have to wait until it hit a <code>&lt;doc&gt;</code> start event, buffer everything until the equivalent <code>&lt;/doc&gt;</code> end event, and emit a NodeSeq of the completed element, and then flush its buffer.</p> <p>How this would work with a Play BodyParser, I am not entirely sure. More updates if I can further clarify what I want to do!</p> <p>Although the whole XML file is large, each <code>&lt;doc /&gt;</code> element by itself is quite small, though I would obviously have to check that the byte buffer didn't exceed a certain size.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload