cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <dani...@nada.kth.se>
Subject Re: Momento and Cocoon [was Re: Jisp 3.0 moved to GPL licence]
Date Mon, 23 Feb 2004 15:16:56 GMT
Upayavira wrote:
> Reinhard Poetz wrote:
>> From: Alan
>>> Working on it. As noted, I have JAXP implemented and SAX interface
>>>    to XUpdate. I have APIs. I am going to start working on services
>>>    next.
>>>       A Cocoon generator that takes a Momento data source and an XSLT
>>>    transform would be a start.
>>>
>>>    I'm not sure how to get information into Momento via Cocoon. I'm
>>>    thinking about some sort of Woody binding, but that goes beyond
>>>    my current understanding of Cocoon.
>>>   
>>
>>
>> speaking without following this thread closly: What about implementing 
>> a Momento source?
>>  
>>
> Yup. Alan, take a look at the XMLDBSource and XMLDBSourceFactory. I 
> think you'll find them reasonably similar to what you might want to do 
> (in src/blocks/xmldb/java/org/apache/cocoon/components/source/impl)
> 
> If you implemented a MomentoSource, and made it implement 
> ModifiableSource, then you would be able to read/write from within 
> Cocoon. With this, you would be able to use Woody's binding 
> functionality to bind forms directly to Momento data.
> 
> You could also do something like the XMLDBTransformer to allow updates 
> (src/blocks/xmldb/java/org/apache/cocoon/transformation/XMLDBTransformer.java). 
> 
> 
> [NB. with an XML:DB interface to Momento, you wouldn't need to do 
> anything to interface to Cocoon].
> 
> Hope this helps.
> 
> Regards, Upayavira

I agree with the above suggestions and would like to provide some more 
technical details.

Pseudo protocol
===============

In Cocoon (or actually Avalon Excalibur), we have a generalization of 
protocols, java.net.URL, called pseudo protocol 
org.apache.excalibur.source.Source, there are also various extensions of 
Source like ModifiableSource, TraversableSource among others. Pseudo 
protocols are an excelent way of separating the location of data with 
what to do with it. If you package a data source as a pseudo protocol 
you can access it by using its URL, e.g. 
momento://dbpath/collection#xpath(foo/bar), through Cocoons source 
resolver. This makes it possible to use sources for ala src attributes 
in the sitemap, the document function in XSLT and XQuery, hrefs in the 
[X|C]IncludeTransformer, in the SourceWritingTransformer and within 
flowscripts.

A MomentoSource would thus give a lot of flexibility in using Momento in 
Cocoon. Especially if it allows using XPath(2.0) in the URLs and if it 
is a modifyable source.

XSLT
====

A MomentoSource would also give a good way to use Momento together with 
XSLT and XQuery in Cocoon. Here we need to extend the ordinary use of 
sources somewhat, let me explain:

The Source interface provides a getInputStream method, in Cocoon some 
Sources implements org.apache.excalibur.xml.sax.XMLizable that provides 
a toSAX method as well. SAX or Streams are probably not the most 
efficient way to communicate with an XML db, so to make the pseudo 
protocol idea usable together with Momento, we should provide a way to 
get a DOM structure from a pseudo protocol. This could be done by 
introducing a new interface:

interface DOMizable {
    org.w3c.domNode getNode();
}

or something similar. If the MomentoSource implements DOMizable, we have 
direct access to nodes in the XML db.

Now we are prepared to connect Momento to XSLT. In Cocoon we can use 
Saxon through the org.apache.cocoon.transformation.TraxTransformer, you 
just need to change cocoon.xconf a little bit to use Saxon instead of 
Xalan. There is also a TraxGenerator in the scratchpad that could be 
used with some small modifications.

I would guess that Momento mainly would be accessed through the document 
function in XSLT and XQuery. Saxon use JAXP 1.1 as external API to the 
transformerand the URLs in the document functions are resolved by using 
an implementation of javax.xml.transform.URIResolver that is provided by 
the TraxTransformer.

The implementation of the URIResolver that is used is 
org.apache.excalibur.xml.xslt.XSLTProcessorImpl in its current 
incarnation it uses the exclaibur source resolver to get the source and 
then it returns a javax.xml.transform.stream.StreamSource. For use with 
Momento we need an implemetation of URIResolver that checks if the the 
source is DOMIzable and in that case returns a 
javax.xml.transform.dom.DOMSource instead. This can be done by extending 
the excalibur XSLTProcessorImpl and change the XSLTProcessor in 
cocoon.xconf.

XQuery
======

XQuery in Saxon use a propertary api, (there are no standard in this 
area yet). So we need a specialized SaxonXQueryGenerator. Saxon use the 
JAXP URIResolver for XQuery also, so the above described mechanisms can 
be used here as well. Unfortionatly Saxon is MPL 1.0 that is not 
compatible with ASL, so we cannot have Saxon as a part of Cocoon :(

                               --- o0o ---

Sorry for all the technical details ;)

As you can see, for reading from Momento, the only Momento specific code 
is in the MomentoSource, everything else is using DOM, JAXP and Cocoon 
APIs. Therefore the proposed mechanisms would give an efficient way of 
using XSLT and XQuery on all data structure that have a DOM interface 
and is accessable through a pseudo protocol. See the thread: [RT] the 
quest for the perfect template language 
http://marc.theaimsgroup.com/?t=104930795600004&r=1&w=2 for a long 
disussion around related ideas.

I would love to see the proposed mechanisms in Cocoon.

/Daniel





Mime
View raw message