This problem is beginning to cause me distress.
I thought I had found a fix for the original problem
(RegexpHeaderSelector not working in map:handle-errors clauses). I
modified my own map:action (called "browser-recognition" in the
snippet below) to return a MIME type (variable "mime-type") in
addition to the other variables it delivers ("browser", "browser-
category", "platform"). The variable "browser-category" returns
"xhtml" in this case, and a serializer called "xhtml" is defined in
the sitemap.
The snippet below results in the complaint (apparently from the
serializer) that it doesn't recognise the type "{browser-
category}"... This seems to indicate that the interpretation of the
variables in "{}" is handled by the components and not by the
sitemap. And worse: that serializers do not support the use of
variables. Is this really the case?
<map:act type="locale">
<map:act type="browser-recognition">
<map:generate src="resources/templates/{browser-
category}.xml" />
<map:transform src="resources/templates/{browser-
category}.xslt">
<map:parameter name="context"
value="{request:scheme}://{request-header:Host}{request:contextPath}/
vimia" />
<map:parameter name="topic"
value="{../../topic}" />
<map:parameter name="content"
value="{../../content}" />
<map:parameter name="language"
value="{../locale}" />
<map:parameter name="browser"
value="{browser}" />
<map:parameter name="browser-category"
value="{browser-category}" />
<map:parameter name="platform"
value="{platform}" />
</map:transform>
<map:transform type="cinclude" />
<map:transform type="i18n">
<map:parameter name="locale" value="{../
locale}" />
</map:transform>
<map:serialize type="{browser-category}" mime-
type="{mime-type}" indent="yes" />
</map:act>
</map:act>
Can anyone help me, please? All i want to do is to generate web pages
in map:handle-errors clauses which have the same look-and-feel as the
ones I generate in map:match clauses: the only complication is that
the design requires that I recognise whether the browser can handle
XHTML or HTML and that I return something in the appropriate form.
Regards
Steve
On 23 Mar 2006, at 23:32, Stephen Winnall wrote:
I am using RegexpHeaderSelector to do some simple content
negotiation. I want to return HTML or
XHTML depending on the target browser's capabilities and have set
up the selector as follows:
<map:selector name="regexp-header"
src="org.apache.cocoon.selection.RegexpHeaderSelector">
<pattern name="xhtml">application/xhtml\+xml</pattern>
<pattern name="html">text/html</pattern>
<pattern name="unknown">^.+$</pattern>
<header-name>accept</header-name>
</map:selector>
I use the following in two places in my sitemap. In a <map:match>
it works as I hoped and delivers XHTML
with MIME type application/xhtml+xml when talking to modern
standard-compliant browsers (including,
but not limited to Gecko-based browsers).
<map:select type="regexp-header">
<map:when test="xhtml">
<map:serialize type="xhtml11" mime-
type="application/xhtml+xml" indent="yes" />
</map:when>
<map:otherwise>
<map:serialize type="html" mime-
type="text/html" indent="yes" />
</map:otherwise>
</map:select>
However, when I use the same snippet in a <map:handle-errors>,
seemingly identical HTML and CSS
sources get returned as HTML with the MIME type text/html. For
Safari and Opera, this is no problem, but
the Gecko family renders the resultant file rather strangely.
Are selectors not allowed in <map:handle-errors>? Has anyone got
any hints about how to make it work?
For completeness, I should add that I invoke the above snippet from
a <map:resource> called "output-error"
defined in the sitemap. The <map:handle-errors> expression is below:
<map:handle-errors>
<map:select type="exception">
<map:when test="not-found">
<map:call resource="output-error">
<map:parameter name="error-no" value="404" />
</map:call>
</map:when>
<map:otherwise>
<map:call resource="output-error">
<map:parameter name="error-no" value="500" />
</map:call>
</map:otherwise>
</map:select>
</map:handle-errors>
I'd be grateful for any enlightenment.
Steve
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]