You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Arnaud Le Hors <le...@jtcsv.com> on 2000/07/04 00:48:12 UTC

Re: Creating multiple DOMs from arbitrarily large input streams

Ed Staub wrote:
> 
> This seems like a common enough problem to trouble the group with...
> 
> We use XML to serialize requests to a variety of processes.  All of these
> processes are written to accept a Node as input.
> 
> For example, imagine that each Request Node requests an "insert" of a
> cluster of records into a database.
> 
> We need to support a batch mode of operation, in which an arbitrarily large
> series of requests are fed to a process.
> 
> A logical way to serialize this (I think) would be to simply concatenate the
> requests together in a larger document:
> 
> <RequestBundle>
>  <Request>...</Request>
>  <Request>...</Request>
>  <Request>...</Request>
>  ...
> </RequestBundle>
> 
> This can't be read as a DOM, because it may be too large.

Note that since the DOM only is an API there is nothing that forces one
to have everything in memory at the same time. Although I haven't seen
any DOM implementation that does something like that I've always thought
it would be a nice thing to have (and an interesting thing to do). One
would have to create nodes when needed and dropped them right away (or
may be not so quickly but after a while).

> I keep thinking that I should be able to
> 
>         use SOX to scan to the first <Request>
>         create a DOM for the first request
>         process the request
> 
>         switch back to SOX, and repeat until done.
> 
> Does this make sense?

Yes (assuming you mean SAX instead of SOX. ;-)

> Is the approach I suggested feasible with Xerces?

Definitely.

>   If so, can you sketch it out a little?

You already have. There is nothing that prevents you from doing exactly
what you just described. You can choose to reuse the same Document,
create elements in it that you destroy at the end of your iteration or
instead get rid of the whole Document and create a new one. That is up
to you.

> How are other people addressing this requirement?

Don't know.

--
Arnaud  Le Hors