cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: CopySourceAction , seems trivial but can't make it works
Date Mon, 27 Sep 2004 06:44:40 GMT
Frédéric Glorieux wrote:
> Thanks in advance
> 
> I checked archives, but...
> 
> I would like to make work this simple idea, when an URI (**.html) is 
> requested for the first time, it's generated and a file is written 
> somewhere ; otherwise, cocoon cache handle. I have implemented a bad 
> patch of my own, directly on pipeline, but if an action can do the 
> job...


IMO, you'd better use Cocoon's CLI which is exactly suited for this job.


> So I tried this
> 
> <map:match pattern="**.html">
>   <map:generate src="{1}.xml"
>   <map:transform src="xml2html.xsl"
>   <map:act type="copy-source" src="cocoon://{1}.html">
>     <map:parameter name="dest" value="context:/test/{1}.html"/>
>   </map:act>
>   <map:serialize/>
> </map:match>
> 
> I guess some infinite loop, but what should I do ? What I like seems 
> more a transformer but SourceWritingTransformer is clearly not what I want.

What is needed for this is a resource-not-exists action that would check 
that a resources does not exist. We don't have this, but the 
resource-exists selector can do the job.

To avoid the infinite loop, you need to separate URL patterns for the 
external request and the actual generation (which could be in an 
internal-only pipeline or a mounted sitemap).

You could then write:

<map:match pattern="production/**.html">
    <map:generate src="{1}.xml"/>
    <map:transform src="xml2html.xsl"/>
    <map:serialize/>
</map:match>

<map:match pattern="**.html">
   <map:select type="resource-exists">
     <map:parameter name="prefix" value="generated/{0}">
     <map:otherwise>
       <map:act type="copy-source" src="cocoon:/production/{0}">
         <map:parameter name="dest" value="generated/{Ø}"/>
       </map:act>
     </map:otherwise>
   </map:select>
   <map:read src="generated/{0}"/>
</map:match>

Note however, that once generated, the document validity will *never* be 
checked unless the generated file is deleted.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message