apache > cocoon
 
Font size:      

ResourceExistsSelector in Cocoon (2.1 legacy document)

Warning
This document was copied as is from the Cocoon 2.1 documentation, but has not yet been fully reviewed or moved to its new home.

ResourceExistsSelector

NAMEresource-exists
WHATThe ResourceExistsSelector component is used to select appropriate sitemap processing depending on the existence of a set of resources.
TYPESelector, Sitemap Component
BLOCKCore
CLASSorg.apache.cocoon.selection.ResourceExistsSelector
SINCECocoon 2.1
CACHEABLEnot 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.

Comments

add your comments