You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Michael Homeijer <M....@devote.nl> on 2001/08/09 12:07:21 UTC
Implementing FileExistSelector
In a part of the sitemap I want to check if a requested file exists,
if it doesn't i want to return the contents of a default file.
Is this the way I should implement something like that
or are the easier methods? :
<map:match pattern="annotation\*"
<map:select type="fileexists">
<map:parameter name="filename" value="annotation\{1}"/>
<map:when test="fileexists">
<map:generate src="annotation\{1}"/>
</map:when>
<map:otherwise>
<map:generate src="annotation\default.xml"/>
</map:otherwise>
</map:select>
<map:transform src="annotation.xsl"/>
</map:match>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Implementing FileExistSelector
Posted by Giacomo Pati <gi...@apache.org>.
Quoting Michael Homeijer <M....@devote.nl>:
> In a part of the sitemap I want to check if a requested file exists,
> if it doesn't i want to return the contents of a default file.
>
> Is this the way I should implement something like that
> or are the easier methods? :
>
> <map:match pattern="annotation\*"
> <map:select type="fileexists">
> <map:parameter name="filename" value="annotation\{1}"/>
>
> <map:when test="fileexists">
> <map:generate src="annotation\{1}"/>
> </map:when>
> <map:otherwise>
> <map:generate src="annotation\default.xml"/>
> </map:otherwise>
> </map:select>
> <map:transform src="annotation.xsl"/>
> </map:match>
This might be one approach. Another one could be with an Action like this:
<map:match pattern="annotation/*"
<map:act type="fileexists" src="annotation/{1}">
<map:parameter name="default" value="annotation/default.xml"/>
<map:generate src="{the-file}"/>
</map:act>
<map:transform src="annotation.xsl"/>
</map:match>
the mentioned Action will check for the file and return a Map containing
"the-file" as the key and the filename as its value depending on the existance
test (either the value of the source attribute or of the parameter "default").
Giacomo
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>
>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>