Browser-Selector in Cocoon
http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Main
User Documentation

Selectors
Overview

Default
Browser Selector

Core
Host Selector
Request Parameter Selector
Request Attribute Selector
Parameter

Optional

BrowserSelector
NAMEbrowser
WHATThe BrowserSelector component is used to select appropriate sitemap processing depending on the User-Agent header value.
TYPESelector, Sitemap Component
BLOCKCore
CLASSorg.apache.cocoon.selection.BrowserSelector
SINCECocoon 2.0
CACHEABLEnot applicable
Description

The BrowserSelector tests the user agent header field against the test attribute of the selectors when clause.

Usage

The BrowserSelector allows to define brower specific sitemap processing.

Sitemap pipeline examples

<map:select type="browser">
  <map:when test="netscape">
  ....
  </map:when>
  <map:when test="explorer">
  ...
  </map:when>
  ...
  <map:otherwise>
  ...
  </map:otherwise>
</map:select>
        
Sitemap component configuration example

<map:selectors...
  <map:selector name="browser" 
    src="org.apache.cocoon.selection.BrowserSelector"
    logger="sitemap.selector.browser" 
    
    <browser name="explorer" useragent="MSIE"/>
    ...
    <browser name="mozilla5" useragent="Moziall/5"/>
    <browser name="netscape" useragent="Mozilla"/>
    
  </map:selectors>
...
Configuration

The configuration section of BrowserSelector specifies a mapping from user-agent strings to symbolic browser names.

Each browser element specifies a name attribute holding the symbolic browser name used in the test attribute expression. The attribute useragent contains a matchable substring of some real user-agent values.

It is allowed to specify for a browser name more than one entry. This way a symbolic browser name is matched by different user-agent substrings. The snippet belows will yield true for test="wap-handset" if the user-agent header contains Nokia, UP, or Wapalizer.

...
  <browser name="wap-handset" useragent="Nokia"/>
  <browser name="wap-handset" useragent="UP"/>
  <browser name="wap-handset" useragent="Wapalizer"/>
...
        
Setup

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

The test attribute of the <map:when> clause must match a browser attribute name value. The value of the test attribute in a <map:when> clause must be declared in a browser name attribute.

Effect on Object Model and Sitemap Parameters

The BrowserSelector has no side effects on the object model, or any sitemap parameters.

Bugs/Caveats

The BrowserSelector adds the response header attribute Vary having value User-Agent indicating that the response differ for different user agents. This information especially meaningfull for an http-proxy server.

History

28-12-02: initial creation

Copyright

Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.

See also

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

Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.