You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Pier Fumagalli <pi...@betaversion.org> on 2004/12/09 23:06:53 UTC

Lame question...

I have some quite-large tables that i use for lookups (categories, 
mostly, and prices). They fit pretty nicely in a DOM in memory, no 
problem, and they almost never change.

Now, I want to access those from XSLT as a variable.

Normally, I would aggregate the source, and pass it in the input to the 
processor, and then do the lookup when I need to.

Big waste of time, though, because normally (in Java) I'd parse the XML 
into a DOM (once) and pass it to the XSLT as a parameter (kind of like 
using the "document" function).

Is there something like that in Cocoon (allow to pass a full DOM as a 
parameter to the XSLT processor) or shall I start coding?

	Pier

Re: Lame question...

Posted by Ralph Goers <Ra...@dslextreme.com>.
Vadim Gritsenko said:
> Pier Fumagalli wrote:
>>
>> Is there something like that in Cocoon (allow to pass a full DOM as a
>> parameter to the XSLT processor) or shall I start coding?
>
> Probably that's what you want:
>    http://issues.apache.org/bugzilla/show_bug.cgi?id=9916
>
> And no, it's not here yet. One workaround I see is to write extension
> which
> would somehow get to the DOM and return it to xslt processor...

It would seem to be fairly trivial to modify TraxTransformer to accept as
parameters the names of input modules it should call along with the
desired attribute. These could then be invoked in getLogicSheetParameters
and added to the parameter map.

Ralph


Re: Lame question...

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Pier Fumagalli wrote:
> I have some quite-large tables that i use for lookups (categories, 
> mostly, and prices). They fit pretty nicely in a DOM in memory, no 
> problem, and they almost never change.
> 
> Now, I want to access those from XSLT as a variable.
> 
> Normally, I would aggregate the source, and pass it in the input to the 
> processor, and then do the lookup when I need to.
> 
> Big waste of time, though, because normally (in Java) I'd parse the XML 
> into a DOM (once) and pass it to the XSLT as a parameter (kind of like 
> using the "document" function).
> 
> Is there something like that in Cocoon (allow to pass a full DOM as a 
> parameter to the XSLT processor) or shall I start coding?

Probably that's what you want:
   http://issues.apache.org/bugzilla/show_bug.cgi?id=9916

And no, it's not here yet. One workaround I see is to write extension which 
would somehow get to the DOM and return it to xslt processor...

Vadim

Re: Lame question...

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Daniel Fagerstrom wrote:
> Pier Fumagalli wrote:
> 
>> I have some quite-large tables that i use for lookups (categories, 
>> mostly, and prices). They fit pretty nicely in a DOM in memory, no 
>> problem, and they almost never change.
>>
>> Now, I want to access those from XSLT as a variable.
>>
>> Normally, I would aggregate the source, and pass it in the input to 
>> the processor, and then do the lookup when I need to.
>>
>> Big waste of time, though, because normally (in Java) I'd parse the 
>> XML into a DOM (once) and pass it to the XSLT as a parameter (kind of 
>> like using the "document" function).
>>
>> Is there something like that in Cocoon (allow to pass a full DOM as a 
>> parameter to the XSLT processor) or shall I start coding?
>>
>>     Pier
> 
> 
> Something you could do that would be usefull for accessing XML databases 
> with DOM interface also (Xindice e.g. IIRC), would be to extend 
> o.a.excalibur.xml.xslt.XSLTProcessorImpl, so that it become DOM aware.
> 
> What needs to be changed is the resolve(String href, String base) method 
> (that is used for handling document(), xsl:include and xsl:import). Now 
> it takes a href, finds a Source and transforms it to a 
> javax.xml.transform.stream.StreamSource. Instead one can start by 
> checking if the Source implements javax.xml.transform.dom.DOMSource, (or 
> DOMizable if we would like to make it analogous to XMLizable), if it 
> does it is just returned from resolve directly.

It's called XMLFragment, org.apache.cocoon.xml.XMLFragment, exists since Cocoon 1.

Vadim


> A similar extension is needed for the transform method so that it also 
> becomes DOMSource aware.
> 
> Then you just creates a source like e.g. XModuleSource that implements 
> DOMSource and finds and return your DOM from somewhere.
> 
> AFAIK neither Saxon or Xalan is as efficient with a DOMSource as with 
> their internal specalized XML tree representation. But it should be much 
> more efficient than to serialize your DOM and build the internal 
> representation.
> 
> /Daniel

Re: Lame question...

Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Pier Fumagalli wrote:
> I have some quite-large tables that i use for lookups (categories, 
> mostly, and prices). They fit pretty nicely in a DOM in memory, no 
> problem, and they almost never change.
> 
> Now, I want to access those from XSLT as a variable.
> 
> Normally, I would aggregate the source, and pass it in the input to the 
> processor, and then do the lookup when I need to.
> 
> Big waste of time, though, because normally (in Java) I'd parse the XML 
> into a DOM (once) and pass it to the XSLT as a parameter (kind of like 
> using the "document" function).
> 
> Is there something like that in Cocoon (allow to pass a full DOM as a 
> parameter to the XSLT processor) or shall I start coding?
> 
>     Pier

Something you could do that would be usefull for accessing XML databases 
with DOM interface also (Xindice e.g. IIRC), would be to extend 
o.a.excalibur.xml.xslt.XSLTProcessorImpl, so that it become DOM aware.

What needs to be changed is the resolve(String href, String base) method 
(that is used for handling document(), xsl:include and xsl:import). Now 
it takes a href, finds a Source and transforms it to a 
javax.xml.transform.stream.StreamSource. Instead one can start by 
checking if the Source implements javax.xml.transform.dom.DOMSource, (or 
DOMizable if we would like to make it analogous to XMLizable), if it 
does it is just returned from resolve directly.

A similar extension is needed for the transform method so that it also 
becomes DOMSource aware.

Then you just creates a source like e.g. XModuleSource that implements 
DOMSource and finds and return your DOM from somewhere.

AFAIK neither Saxon or Xalan is as efficient with a DOMSource as with 
their internal specalized XML tree representation. But it should be much 
more efficient than to serialize your DOM and build the internal 
representation.

/Daniel

Re: Lame question...

Posted by Micah Dubinko <md...@snapbridge.com>.
I could be way off, but...

Have you tried including the data in the stylesheet itself and using 
document() to self-reference?

.micah

Pier Fumagalli wrote:

> I have some quite-large tables that i use for lookups (categories, 
> mostly, and prices). They fit pretty nicely in a DOM in memory, no 
> problem, and they almost never change.
>
> Now, I want to access those from XSLT as a variable.