You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Amanda Drake <ad...@oakgrovesoftware.com> on 2002/09/04 18:30:48 UTC

Browser version detection in cocoon

I am using Cocoon 2.0.3 and Tomcat 4.0.4.  I am able to configure the 
sitemap.xmap to select a stylesheet based on the browser type using the 
following:

<?xml version="1.0"?>

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

 ...

  <map:selectors default="browser">
   <map:selector name="browser"
     src="org.apache.cocoon.selection.BrowserSelector">
    <browser name="explorer" useragent="MSIE"/>
    <browser name="netscape" useragent="Mozilla"/>
   </map:selector>
   <map:selector name="parameter"
     src="org.apache.cocoon.selection.ParameterSelector"/>
  </map:selectors>

 ...

  <map:pipeline>
   <map:match pattern="hello.html">
      <map:generate src="content/xml/hello-page.xml"/>

      <map:select type="browser">
        <map:when test="explorer">
          <map:transform src="style/xsl/explorer-page2html.xsl"/>
        </map:when>
        <map:when test="netscape">
          <map:transform src="style/xsl/netscape-page2html.xsl"/>
        </map:when>
        <map:otherwise>
          <map:transform src="style/xsl/simple-page2html.xsl"/>
        </map:otherwise>
      </map:select>

    <map:serialize type="html"/>
   </map:match>

  </map:pipeline>
 </map:pipelines>

</map:sitemap>

---

Seems to work fine.  But when I want to choose the stylesheet based on the 
browser version, I have problems.  I can change the browser selection to:

 ...

  <map:selectors default="browser">
   <map:selector name="browser"
     src="org.apache.cocoon.selection.BrowserSelector">
    <browser name="explorer" useragent="HappyHappyJoyJoy"/>
    <browser name="netscape" useragent="Mozilla"/>
   </map:selector>
   <map:selector name="parameter"
     src="org.apache.cocoon.selection.ParameterSelector"/>
  </map:selectors>

 ...

And it still uses the explorer stylesheet transformation.  I can comment out 
the entire block above and it still goes along its merry way.  The docs that I 
have seen refer to a cocoon.properties file, but I don't have one with 2.0.

What I want to be able to do is select the specific browser version.  I want to 
be able to use a specific xsl stylesheet for IE 6, IE 5, Netscape 6, etc.  This 
is the first time that I've worked with Cocoon, so I may have overlooked 
something.

Thanks for your help!

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>