You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Severin Gehwolf <se...@jerboaa.org> on 2007/11/29 10:55:12 UTC

Cocoon and content-negotiation

Hi!

I am new to cocoon and I am wondering if there is a "cocoon-way" of
content-negotiation, similar to that of Apache2? The problem I am faced
with is to select a particular XML file with the best-matching language
extension according to users Accept-Language HTTP headers.
Unfortunately, Apache2's language negotiation comes in after the request
is dispached to Cocoon. We have the following simplified setup:

Request
|
| httpd (Apache2)
| |
| `-> mod_rewrite/mod_proxy
|      |
|      `-> Cocoon
|			     |
|<---------+


So for example:

The HTTP request

GET /index.html HTTP/1.1
Host: foo.tld
Accept: text/html
Accept-Language: en,de;q=0.7,*

should trigger Cocoon to generate 'index.xml.en' (<map:generate
src="index.xml.en"/>).

Is there a way to achieve this with plain cocoon sitemaps (no custom
Selector/external Java code)? As far as I know a hook would be to use the
'RegexpHeaderSelector'. However, I am not really convinced if this is
the best approach for such an issue?! Any suggestions greatly
appreciated. I have Cocoon v.2.1.10 here.

Thanks!
Severin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and content-negotiation

Posted by Tobia Conforto <to...@linux.it>.
Severin Gehwolf wrote:
> select a particular XML file with the best-matching language extension
> according to users Accept-Language HTTP headers.

This is usually achieved in Cocoon using the LocaleAction:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/acting/LocaleAction.html

Other kinds of content negotiation, such as detecting patterns in the
HTTP Accept header, can be performed with the RegexpHeaderSelector:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/selection/RegexpHeaderSelector.html
or similar selectors and matchers that access the HTTP headers.


Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org