apache > cocoon
 

DateSelector in Cocoon

DateSelector

NAME

date

WHAT

The DateSelector component is used to select appropriate sitemap processing depending on the current date, and time.

TYPE

Selector, Sitemap Component

BLOCK

Scratchpad

CLASS

org.apache.cocoon.selection.DateSelector

SINCE

Cocoon 2.1

CACHEABLE

not applicable

Description

The DateSelector tests the current date, and time against the test attribute of the selectors when clause.

Usage

The DateSelector allows to define date, and time specific sitemap processing. This way Cocoon can do date, and time specific sitemap processing.

Sitemap pipeline examples

<map:select type="daytime">
  <map:when test="night">
    <!-- do something for night publishing -->
    <map:read src="resources/{2}-night.css" mime-type="text/css>
  </map:when>
  <map:when test="morning">
    <!-- do something for morning publishing -->
    <map:read src="resources/{2}-morning.css" mime-type="text/css>
  </map:when>
  ...
  <map:otherwise>
    <!-- define for completness, and if selecting fails due to errors -->
  </map:otherwise>
</map:select>

Sitemap component configuration example

The following snippet defines a DateSelector named daytime. A day is partioned into four daytime areas: night, morning, afternoon, and evening. These daytime names are used to define daytime specific pipeline processing for each daytime area.

<map:selectors default="browser">
  ...
  <map:selector type="daytime" src="org.apache.cocoon.selection.DateSelector">
    <before name="night" date="06:00:00" dateformat="HH:mm:ss"/>
    <before name="morning" date="12:00:00" dateformat="HH:mm:ss"/>
    <before name="afternoon" date="18:00:00" dateformat="HH:mm:ss"/>
    <before name="evening" date="23:59:59" dateformat="HH:mm:ss"/>
  </map:selector>
...
</map:selectors>

Configuration

Explain the sitemap selector configuration, options when declaring date selector

Setup

Explain the sitemap selector setup, ie options when using date selector

Effect on Object Model and Sitemap Parameters

Bugs/Caveats

Describe limitation, bugs of DateSelector

History

11-28-03: initial creation

See also

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