forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <>
Subject Re: [RT] InputModuleTransformer for linking (Re: [RT] LinkTranslator Usage)
Date Mon, 16 Dec 2002 12:45:48 GMT
On Mon, Dec 16, 2002 at 09:51:55AM +0100, Christian Haul wrote:
> On 15.Dec.2002 -- 03:36 PM, Jeff Turner wrote:
> > So anyway, I'm thinking, how about implementing this as a generic
> > InputModuleTransformer, which is configured with a) an InputModule, b) an
> > XPath expression of nodes to transform.  So to transform hrefs in links,
> > we'd have:
> > 
> > <map:transformers>
> >   <map:transformer name="inputmodule" src="o.a.c.t.InputModuleTransformer">
> >     <input-module>linkmap</input-module>
> >     ...
> >     <transformed-nodes>//link/@href</transformed-nodes>
> >   </map:transformer>
> > </map:transformers>
> > 
> > Where 'linkmap' is defined in cocoon.xconf as:
> > 
> > <component-instance name="linkmap" class="o.a.c.c.modules.input.XMLFileModule"
> >     <file src="context://linkmap.xml"/>
> > </component-instance>
> > 
> > Since XMLFileModule can use any Source, so can our linking system.  Want
> > to link to whatever's the top Slashdot article?  Add a 'slashdot'
> > InputModule (in the samples sitemap), and add <link
> > href="slashdot:/*:RDF/item[1]/title}">Slashdot Headline</link> to your
> > XML.
> > 
> > What do people think?  Is this the base for a majorly cool linking
> > system, or am I missing something?
> Jeff,
> I think this is a great idea! Some ideas:
> *) It might be nice to use the syntax from sitemap, i.e. the
>    transformer would not be bound to a single module but dynamically
>    look them up "{linkmap:something}" 

Yes, I'm currently cut-pasting sections from * to support

>    I guess the "..." above indicate that more than one module may be
>    used but I wonder what it buys to have their declaration locally to
>    the transformer.

I guess there isn't much reason to explicitly list the available input
modules.  I was copying ChainMetaModule.

>    Granted, this way you can deviate from the global configuration of a
>    module.  Maybe the transformer could use all modules and use a
>    special configuration for those listed in the configuration section?

I don't understand.. what configuration section?  Why would a Transformer
try to configure InputModules?  Can't the transformer just say"blah") and rely on the cocoon.xconf configuration
of the 'blah' InputModule?

>    For the input.xsl logicsheet I have created a simple helper class
>    that handles a list of modules during execution. Perhaps this class
>    could be used by the transformer (would need some additions for the
>    configurations):

Thanks, that is very helpful.  I'm way out of my depth with this stuff.

> *) limiting the transformer to nodes matching an XPath expression is
>    cool. But it might be expensive: It might require the transformer
>    to keep / build a DOM representation of the document so that the
>    XPathProcessor can be used.

Yes, so I discovered.  It is very hard to divide a DOM into two sets of nodes,
those selected by XPath and those not.    

>    Alternatives could be to act on every attribute (expensive), act on
>    every attribute of elements belonging to the target namespace, dito
>    but only certain attributes or specific elements. Those could be
>    decided without knowledge of the rest of the document but appear
>    not to restrict the application too much.

Currently I'm checking a configurable list of attributes (eg href, src)
for ':', and processing those.  So <link href="site:/primer"> would
trigger"site"), and then
module.getAttribute("/primer", ...).  I haven't figured out the '...'
part yet:)


PS: There is a bug in ChainMetaModule, caused by too few brackets.  The 'else'
is associating with the wrong 'if':

public void dispose() {

    if (!this.initialized.booleanValue())
        if (getLogger().isErrorEnabled())
            getLogger().error("Uninitialized Component! dispose() FAILING");
            if (this.inputSelector != null) {

                for (int i=0; i<this.inputs.length; i++) {
                    if (this.inputs[i].input != null)


> Cheers,
> 	Chris.
> -- 
> C h r i s t i a n       H a u l
>     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

View raw message