You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stephen Winnall <st...@winnall.ch> on 2006/02/17 01:01:45 UTC
is there a BrowserAction?
I am looking for a way to get information about the user's browser in
a transformation in a
Cocoon pipeline. I may be looking for the wrong thing, or trying to
go about it in the wrong
way, so I'd be grateful for any advice.
I want to handle browser differences in an XSLT file rather than in
the sitemap. I realise that
I could use BrowserSelector if I wanted the logic to be in the
sitemap, but I think I have a
cleaner solution if I can put the logic into a transformation. An
action along the lines of
LocaleAction would seem to me to fit the bill.
I've spent some time googling for BrowserAction and variations of
that, but I haven't found
anything and suspect that I may have to write the thing myself. Does
such a thing already
exist? Or is there already an elegant way of passing the name of the
browser (ideally with
version and OS) to an XSLT in a pipeline?
Steve
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: is there a BrowserAction?
Posted by Stephen Winnall <st...@winnall.ch>.
Andrew, Tony
Thanks for your feedback.
I'm a little concerned about the overhead involved in getting the
information I want out of the
user agent string (browser, version and platform), the more so since
in the worst case it would
be done for every Cocoon request. I like the way LocaleAction
"remembers" what it has done
in the session and I want to try and do something like that.
So I am taking the plunge and writing a BrowserAction. When it's
working for me, I'll make it
available as alpha-code if anyone else is interested.
Steve
On 17 Feb 2006, at 01:01, Stephen Winnall wrote:
> I am looking for a way to get information about the user's browser
> in a transformation in a
> Cocoon pipeline. I may be looking for the wrong thing, or trying to
> go about it in the wrong
> way, so I'd be grateful for any advice.
>
> I want to handle browser differences in an XSLT file rather than in
> the sitemap. I realise that
> I could use BrowserSelector if I wanted the logic to be in the
> sitemap, but I think I have a
> cleaner solution if I can put the logic into a transformation. An
> action along the lines of
> LocaleAction would seem to me to fit the bill.
>
> I've spent some time googling for BrowserAction and variations of
> that, but I haven't found
> anything and suspect that I may have to write the thing myself.
> Does such a thing already
> exist? Or is there already an elegant way of passing the name of
> the browser (ideally with
> version and OS) to an XSLT in a pipeline?
>
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: is there a BrowserAction?
Posted by Tony Edwards <te...@civica.com.au>.
Hi Stephen,
You can use a selector and pass a parameter into the tranform:
<!-- Main rendering matcher -->
<map:resource name="html">
<!--map:transform src="xsl/pifnamespaces.xsl"/>-->
<map:select type="browser">
<map:when test="explorer">
<map:transform src="xsl/site2xhtml.xsl">
<map:parameter name="browser" value="explorer" />
<map:parameter name="version_num"
value="{global:version_num}"/>
</map:transform>
</map:when>
<map:when test="netscape">
<map:transform src="xsl/site2xhtml.xsl">
<map:parameter name="browser" value="netscape" />
<map:parameter name="version_num"
value="{global:version_num}"/>
</map:transform>
</map:when>
<map:when test="opera">
<map:transform src="xsl/site2xhtml.xsl">
<map:parameter name="browser" value="netscape" />
<map:parameter name="version_num"
value="{global:version_num}"/>
</map:transform>
</map:when>
<map:otherwise>
<map:transform src="xsl/site2xhtmlPIE.xsl">
<map:parameter name="browser" value="Pocket
Explorer" />
<map:parameter name="version_num"
value="{global:version_num}"/>
</map:transform>
</map:otherwise>
</map:select>
In your xsl just 'declare' a browser parameter and use it to vary the
html etc, eg:
<xsl:if test="$browser = 'explorer'">
<script type="text/javascript" src="fixed.js"></script>
<script type="text/javascript">
<!--//-->
Hope this helps.
Regards,
Tony
Stephen Winnall wrote:
> I am looking for a way to get information about the user's browser in
> a transformation in a
> Cocoon pipeline. I may be looking for the wrong thing, or trying to go
> about it in the wrong
> way, so I'd be grateful for any advice.
>
> I want to handle browser differences in an XSLT file rather than in
> the sitemap. I realise that
> I could use BrowserSelector if I wanted the logic to be in the
> sitemap, but I think I have a
> cleaner solution if I can put the logic into a transformation. An
> action along the lines of
> LocaleAction would seem to me to fit the bill.
>
> I've spent some time googling for BrowserAction and variations of
> that, but I haven't found
> anything and suspect that I may have to write the thing myself. Does
> such a thing already
> exist? Or is there already an elegant way of passing the name of the
> browser (ideally with
> version and OS) to an XSLT in a pipeline?
>
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Tony Edwards
¯¯¯¯¯¯¯¯¯¯¯¯
Analyst/Programmer
Dip Teach PE
Dip Comp. Studies
p: 02 4941 9400
f: 02 4941 9499
--
This email is from Civica Pty Limited and it, together with
any attachments, is confidential to the intended recipient(s)
and the contents may be legally privileged or contain
proprietary and private information. It is intended solely
for the person to whom it is addressed. If you are not an
intended recipient, you may not review, copy or distribute
this email. If received in error, please notify the sender
and delete the message from your system immediately. Any
views or opinions expressed in this email and any files
transmitted with it are those of the author only and may
not necessarily reflect the views of Civica and do not create
any legally binding rights or obligations whatsoever. Unless
otherwise pre-agreed by exchange of hard copy documents
signed by duly authorised representatives, contracts may not
be concluded on behalf of Civica by email. Please note that
neither Civica nor the sender accepts any responsibility for
any viruses and it is your responsibility to scan the email
and the attachments (if any). All email received and sent by
Civica may be monitored to protect the business interests of
Civica.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: is there a BrowserAction?
Posted by Andrew Stevens <at...@hotmail.com>.
>From: Stephen Winnall <st...@winnall.ch>
>Date: Fri, 17 Feb 2006 01:01:45 +0100
>
>I've spent some time googling for BrowserAction and variations of that,
>but I haven't found
>anything and suspect that I may have to write the thing myself. Does such
>a thing already
>exist? Or is there already an elegant way of passing the name of the
>browser (ideally with
>version and OS) to an XSLT in a pipeline?
Well, I was about to suggest you could use the request input module to get
the user-agent header, and pass it into your XSLT with a map:parameter.
However, I noticed in the docs [1] that there's also a
HeaderAttributeModule; that looks like it can return the request header
values too, so take your pick.
Once you've got the user agent string into the XSL, you just need to do some
string manipulation in there to figure out what browser/version/platform it
is.
Andrew.
[1] http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org