You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jo...@notes.uni-paderborn.de on 2002/07/26 17:23:39 UTC

How to switch to another resource if one resource is not available?

Hi,

im a beginner with cocoon. Maybe it is an easy question, but i don´t know
where to start.

I am just playing a bit round with the sitemap, generaters, serializers and
so on.

Now i wonder, how i can set up a matcher for JPG, that delivers a JPG if it
is available and if it is not available delivers a SVG, which can be
serialized to JPG.
So to the outside it shouldn´t matter if the picture is generated from JPG
or SVG.

This is map:match for jpg as source:

       <map:match pattern="images/**.jpg">
          <map:read src="images/{1}.jpg" mime-type="image/jpg"/>
       </map:match>

and this for svg as source:

       <map:match pattern="images/**.jpg">
          <map:generate src="images/{1}.svg"/>
          <map:serialize type="svg2jpeg"/>
       </map:match>

So how do i combine this to both match "images/**.jpg"?
Is there any kind of error handling?

Thank you


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: How to switch to another resource if one resource is not available?

Posted by Nicola Ken Barozzi <ni...@apache.org>.
Joern_Hoos@notes.uni-paderborn.de wrote:
> Hi,
> 
> im a beginner with cocoon. Maybe it is an easy question, but i don´t know
> where to start.
> 
> I am just playing a bit round with the sitemap, generaters, serializers and
> so on.
> 
> Now i wonder, how i can set up a matcher for JPG, that delivers a JPG if it
> is available and if it is not available delivers a SVG, which can be
> serialized to JPG.
> So to the outside it shouldn´t matter if the picture is generated from JPG
> or SVG.
> 
> This is map:match for jpg as source:
> 
>        <map:match pattern="images/**.jpg">
>           <map:read src="images/{1}.jpg" mime-type="image/jpg"/>
>        </map:match>
> 
> and this for svg as source:
> 
>        <map:match pattern="images/**.jpg">
>           <map:generate src="images/{1}.svg"/>
>           <map:serialize type="svg2jpeg"/>
>        </map:match>
> 
> So how do i combine this to both match "images/**.jpg"?
> Is there any kind of error handling?

Well, you have to tell Cocoon if the image comes from SVG or JPG.

I think you want to see: if jpg is present, use it, else use the svg and 
transform it.

You will need a single match, and inside a resource-exists action, that 
checks if the jpg exists on disk.

If it does, put the first piece of code inside the action tag, else put 
the svg one after the action tag.

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>