apache > cocoon
 

ResourceExistsSelector in Cocoon

ResourceExistsSelector

NAME

resource-exists

WHAT

The ResourceExistsSelector component is used to select appropriate sitemap processing depending on the existence of a set of resources.

TYPE

Selector, Sitemap Component

BLOCK

Core

CLASS

org.apache.cocoon.selection.ResourceExistsSelector

SINCE

Cocoon 2.1

CACHEABLE

not applicable

Description

The ResourceExistsSelector selects the first of a set of Resources (usually files) that exists in the context.

Usage

Pipelines can be built based on the existence of files, for example building a PDF from XSL-FO or a higher-level XML format.

Sitemap pipeline examples

<map:match pattern="**.html"> 
  <map:select type="resource-exists">
    <map:when test="content/{1}.xml">
      <map:generate src="content/{1}.xml" />
      <map:transform src="stylesheets/page2html.xsl" />
    </map:when>
    <map:otherwise>
      <map:generate src="resources/html/{1}.html" />
    </map:otherwise>
  </map:select>
  <map:serialize type="html"/>
</map:match>
        

Sitemap component configuration example

<map:selectors...

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

Configuration

The optional prefix parameter is prepended to all test expressions before evaluation. The default prefix is '/', meaning that all expressions are relative to the context root, unless explicitly overridden.

Setup

Setting up a ResourceExistsSelector includes choosing the <map:when> test expressions, and an optional <map:otherwise> clause.

History

03-19-03: initial creation

See also

A general documentation about selectors is available at Matchers and Selectors.