This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Selecting between multiple stylesheets on same xml file (apache/cocoon)


Hi,

> I'm using an apache/cocoon setup, with an xml newsfeed of about 5/6
> categories of stories. With perhaps with php script, I want to
> detect the user's platform, eg normal desktop/laptop, PocketPC,
> Palm, etc using HTTP_USER_AGENT, also category(s) of user's news
> preferences, particular story etc, then select the appropriate xsl
> stylesheet to serve up content particular to their needs.
>
> At the moment, i'm using several copies of the same xml file
> referencing different stylesheets, and obviously this is ridiculous!

Yep. Cocoon has some built-in support that allows you to have multiple
xml-stylesheet processing instructions in the same XML document point
to different stylesheets for different media.

First you need to go into the cocoon.properties file and find the User
Agents (Browsers) section. There you'll find a list of user agents,
each of which is given a label. Some share labels, so 'Nokia', 'UP'
and 'Wapalizer' all have the label 'wap'. You should change this list
so that it categorises the user agents that you're interested in into
the groups for which you have different stylesheets.

Then you should go into your XML document and add different
xml-stylesheet processing instructions for each of the stylesheets.
Use the media pseudo-attribute to point to one of the labels that
you've set up. For example, given the standard settings you could do
something like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" media="explorer" href="msie.xsl"?>
<?xml-stylesheet type="text/xsl" media="netscape" href="netscape.xsl"?>
<?xml-stylesheet type="text/xsl" media="wap" href="wap.xsl"?>
...
<?cocoon-process type="xslt"?>
...

Restart Cocoon and it should all work smoothly.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]