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

"Mark R. Diggory" <mdiggory-Mahy8Y1M33PaZwrp7/[email protected]> Wed, 28 Sep 2005 10:59:25 -0400
Newsgroups gmane.comp.db.dbxml.general
Message-ID <[email protected]>
I really like the idea of the event based api you've discussed and am 
looking forward to using it when it comes out. For now, I get by with 
buffering the content.

There are two other areas of integration that I can see for JAXP like 
processing.

Saxon has an SPI layer for transforming object models other than w3c 
DOM. Implementing this for the BDBXML java API would mean that one can 
write an JAXP transform directly on XMLValue nodes instead of having to 
convert them to w3c DOM first. (Very Cool).

JAXP has an XPath API, for which the same could be implemented. I have 
no doubt that in the future JAXP's XPath API will migrate to XQuery (or 
a JAXP XQuery API will come into existence) and that this will be very 
analogous to Saxons XQuery implementation and the an SPI similar to 
Saxons will arise in JAXP.

Finally, do you guys have an answer for my question? It was buried 
pretty deep in the message, so I understand it getting missed:

>>>> 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?

Cheers,
Mark

John Snelson wrote:
> 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
> 
> 


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