You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Jörn Nettingsmeier <po...@uni-duisburg.de> on 2006/06/25 16:16:13 UTC

cocoon sitemaps: how do i re-use transforming resources from other modules?

hi !


i have the following scenario:

two modules:

"xmldb", a module to query an exist xml database. in its sitemap it 
contains a resource "xmldb", which is a complex chain of transformers:

   <map:resource name="xmldb">
     <!-- expand any jx parameter references in the query -->
     <map:transform type="jx"/>
     <!-- transform xq:query element into cinclude xmldb query -->
     <map:transform type="xslt" src="xslt/xmldb-preprocessing.xsl"/>
     <!-- perform the query by sending a POST request
          to the xmldb query handler -->
     <map:transform type="cinclude">
       <map:parameter name="support-caching" value="false"/>
     </map:transform>
     <!-- clean up result from the xqueryhandler -->
     <map:transform type="xslt" src="xslt/xmldb-postprocessing.xsl"/>
   </map:resource>


"people", a module that generates staff pages by querying said database.
in the "people" sitemap, i want to re-use that resource to keep things 
modular:

<map:generate src="queryPerson.xml"/>
<map:call resource="cocoon://modules/xmldb/xmldb"/>
<map:transform type="xslt" src="xslt/person2html.xsl"/>
<map:serialize type="xml"/>

of course the map:call does not work, because resources have to be local.

how can i accomplish this? iiuc i cannot use an entire pipeline with 
map:mount, because the generation must happen in the "people" sitemap, 
(the people module contains the query file).

i could think of having a callback-style pipeline in "xmldb" that gets 
passed a src parameter of the form 
"cocoon://modules/people/queryPerson.xml", but i would like to avoid it 
because it seems unidiomatic and rather complicated.


thanks in advance for any ideas!

jörn



-- 
"Open source takes the bullshit out of software."
	- Charles Ferguson on TechnologyReview.com

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: cocoon sitemaps: how do i re-use transforming resources from other modules?

Posted by Joern Nettingsmeier <po...@uni-due.de>.
solprovider, andreas, thanks for those pointers!



-- 
"Án nýrra verka, án nútimans, hættir fortíðin að vekja áhuga."
"Without new works, without the present the past will cease to be of
interest."
        - Ásmundur Sveinsson (1893-1982)

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: cocoon sitemaps: how do i re-use transforming resources from other modules?

Posted by so...@apache.org.
On 6/25/06, Jörn Nettingsmeier <po...@uni-duisburg.de> wrote:
> I have the following two modules:
> "xmldb", a module to query an exist xml database. in its sitemap it
> contains a resource "xmldb", which is a complex chain of transformers:
>    <map:resource name="xmldb">
>      <!-- expand any jx parameter references in the query -->
>      <map:transform type="jx"/>
>      <!-- transform xq:query element into cinclude xmldb query -->
>      <map:transform type="xslt" src="xslt/xmldb-preprocessing.xsl"/>
>      <!-- perform the query by sending a POST request
>           to the xmldb query handler -->
>      <map:transform type="cinclude">
>        <map:parameter name="support-caching" value="false"/>
>      </map:transform>
>      <!-- clean up result from the xqueryhandler -->
>      <map:transform type="xslt" src="xslt/xmldb-postprocessing.xsl"/>
>    </map:resource>
>
> "people", a module that generates staff pages by querying said database.
> in the "people" sitemap, i want to re-use that resource to keep things
> modular:
>
> <map:generate src="queryPerson.xml"/>
> <map:call resource="cocoon://modules/xmldb/xmldb"/>
> <map:transform type="xslt" src="xslt/person2html.xsl"/>
> <map:serialize type="xml"/>
>
> of course the map:call does not work, because resources have to be local.
> how can i accomplish this? iiuc i cannot use an entire pipeline with
> map:mount, because the generation must happen in the "people" sitemap,
> (the people module contains the query file).
>
> i could think of having a callback-style pipeline in "xmldb" that gets
> passed a src parameter of the form
> "cocoon://modules/people/queryPerson.xml", but i would like to avoid it
> because it seems unidiomatic and rather complicated.

I think you understand the issue.  You need to change both modules to
make it work.  Make your "callback" pipeline generic so it works with
any module.

See Lenya1.3's "live" and "cache" Modules for an example.
- The "live" Module constructs a special match.   If the "cache"
Module is used in the Publication, "live" uses map:mount to pass
control to the cache Module.  (It also checks for a "homepage" Module,
but that is a direct transfer of control.)
- The "cache" Module decides if caching is warranted, and checks if
the page is in the cache.  If the page needs to be generated, it uses
map:generate to get the results of a pipeline in the calling Module.

NOTE: There is a bug in map:read so it cannot be used in a pipeline
called with map:generate.  This was apparently deliberate poor
programming design in Cocoon.  That is why "live" needed to use
map:mount to pass to "cache".  Without this bug, map:generate could
have been used for much simpler code.  You may be able to pass control
between the Modules without map:mount.

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: cocoon sitemaps: how do i re-use transforming resources from other modules?

Posted by Andreas Hartmann <an...@apache.org>.
Jörn Nettingsmeier wrote:

[...]

> "xmldb", a module to query an exist xml database. in its sitemap it 
> contains a resource "xmldb", which is a complex chain of transformers:

Unfortunately I don't know a straightforward way to accomplish that,
but you might want to put the Virtual Pipeline Component discussion [1]
on your watch list. I don't know the current implementation state, though.

[1] 
http://mail-archives.apache.org/mod_mbox/cocoon-dev/200407.mbox/%3C40FFC48D.3030102@apache.org%3E

-- Andreas




-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org