Apache » Cocoon »

  Cocoon Core
      2.2
   homepage

Cocoon Core 2.2

ResourceExistsSelector

Summary

Selects the first of a set of Resources (usually files) that exists.

Basic information

Component typeSelector
Cocoon blockcore
Java classorg.apache.cocoon.selection.ResourceExistsSelector
Name in Sitemap
Cacheable

Documentation

A parameter 'prefix',

<map:parameter src="prefix" value="<code>some/path</code>"/>

may be supplied to the selector instance.  This prefix is prepended to all
test expressions before evaluation.  The default prefix is '' (empty string),
meaning that all expressions are relative to the current sitemap, unless
explicitly overridden.

NOTE:
Provided resource URI is resolved as Source, relative to the current
sitemap, which differs from behavior of selector in previous versions.
To resolve resource paths relative to the context root, provide prefix
parameter:

<map:parameter name="prefix" value="context://"/>

For example, we could define a ResourceExistsSelector with:

<map:selector name="resource-exists"
                    logger="sitemap.selector.resource-exists"
                    src="org.apache.cocoon.selection.ResourceExistsSelector" />

And use it to build a PDF from XSL:FO or a higher-level XML format with:

<map:match pattern="**.pdf">
  <map:select type="resource-exists">
    <map:when test="context/xdocs/{1}.fo">
      <map:generate src="content/xdocs/{1}.fo" />
    </map:when>
    <map:otherwise>
      <map:generate src="content/xdocs/{1}.xml" />
      <map:transform src="stylesheets/document2fo.xsl" />
    </map:otherwise>
  </map:select>
<map:serialize type="fo2pdf" />