Re: [bdbxml] XMLInputStreams and regular InputStreams and w3c DOM objects.

John Snelson <[email protected]> Wed, 28 Sep 2005 15:51:51 +0100
Newsgroups gmane.comp.db.dbxml.general
Message-ID <[email protected]>
Hi Mark,

I understand what you are trying to do, and no, this is not possible 
with the current API without buffering the document's content.

In the future we plan to add an event based API that will allow both 
push and pull access to a SAX like event class for adding and updating 
documents. However, we have no firm plans as to exactly when this will 
be implemented.

John

Mark R. Diggory wrote:
> My example failed to show this case clearly, heres a better one:
> 
>> JAXP Transformer --> JAXP Result --> OutputStream --> XMLDocument --> DB
> 
> 
> Transformer trans = TransformerFactory.newFactory().newTransformer();
> 
> XMLDocument doc = ...;
> 
> trans.transform(
>     new StreamSource(my_input_stream),
>     new StreamResult(doc.getContentWriter())
> );
> 
> Point being that the result of the transform could get pushed to the 
> writer or OutputStream gotten from the XMLDocument. The writer would be 
> used to push the content into the XMLDocument.
> 
> -Mark
> 
> Mark R. Diggory wrote:
> 
>> John,
>>
>> This is great for "pulling" contents of the db.
>>
>> DB --> XMLDocument --> InputStream --> JAXP Source
>>
>> Will it work for writing? Seems BDBXML uses a "pull" strategy for 
>> writing to the DB as well this is somewhat different than JAXP where 
>> transform results are "pushed" to an output stream.
>>
>> JAXP Transformer --> JAXP Result --> OutputStream --> XMLDocument --> DB
>>
>> In JAXP, "StreamResult" can take a Writer or an OutputStream as a 
>> target for writing XSLT output to. Is there an analog to this in the 
>> DB? For instance XMLOutputStream which one could push transform 
>> results into the DB with?
>>
>>
>> Finally an example of this usage would be in the XQuery API,
>>
>> XMLResult is the product of an XQuery executed against the DB. I can 
>> see the need for multiple result formats for XMLResults as well, for 
>> this I do see that I can get back an XMLDocument as opposed to an 
>> XMLValue DOM:
>>
>> XMLResult.next(XmlDocument document)
>>
>> For instance, I may want to stream XMLResults directly to an 
>> OutputStream without retaining the XMLValues in memory (System.out or 
>> ServletResponse.getWriter())
>>
>> ...
>> XMLResult result = ...;
>> XMLDocument doc = null;
>> result.next(doc);
>>
>> Question: When completing an XMLQuery against the DB, are the results 
>> in memory (as XMLValues) at execution or are they completed as I 
>> iterate over the XMLResult? The question is more specifically, If I 
>> can do something like "result.next(doc);" is the XMLDocument just 
>> backed by the in-memory XMLValue DOM or is it backed directly by the 
>> Database?
>>
>> Either way I can use a JAXP identity transform to push the document to 
>> an OutputStream
>>
>> Transformer trans = TransformerFactory.newFactory().newTransformer();
>>
>> trans.transform(
>>    new StreamSource(doc.getContentAsXmlInputStream()),
>>    new StreamResult(System.out)
>> );
>>
>> -Mark Diggory

-- 
John Snelson, Berkeley DB XML Engineer
Sleepycat Software, Inc
http://www.sleepycat.com

Contracted to Sleepycat through Parthenon Computing Ltd
http://blog.parthcomp.com/dbxml


------------------------------------------
To remove yourself from this list, send an
email to [email protected]