views:

493

answers:

2

I have an XML file that I want the user to be able to see with two different stylesheets. The stylesheets are mutually exclusive, so only one of them should be active at a a time.

I tried adding the following to the top of my XML file:

<?xml-stylesheet type="text/xsl" href="brief.xsl" title="Breif" ?>
<?xml-stylesheet type="text/xsl" href="detailed.xsl" title="Detailed" alternate="yes" ?>

What I would expect to happen was that brief.xsl would be used as the default stylesheet, and "Detailed" would show up as an item in the "View -> Page Style" menu, but Firefox seems to ignore the second stylesheet (I only get the items "No Style" and "Basic Page Style", which are the default ones for every page).

Does Firefox not support the alternate attribute, or am I doing something (else) wrong? Do other browsers support this?

A: 

I don't know about XML specifically, but I have seen it work with alternate stylesheets for HTML.

As an example, look at this site: http://www.thesitewizard.com/javascripts/change-style-sheets.shtml

it uses this code:


link rel="stylesheet" type="text/css" href="../include/style.css" title="blue" media="screen" /
link rel="alternate stylesheet" type="text/css" href="../include/change-style-sheets/style-alternate.css" title="grey" media="screen" /

I'm using firefox 2.0.0.19, and "view->page style" shows "no style", "blue", and "grey". So, at least in HTML, firefox can handle multiple, alternate stylesheets.

YenTheFirst
+1  A: 

Firefox 3.5 Nightly honors the alternate, but there's no built-in functionality to swap the xml-stylesheets, it is only trying to swap stylesheets for the resultant document.

IE 6.0-8.0 do not support alternate="yes" in the xml-stylesheet processing rule. So it will process the first one, and ignore the second.

Mister Lucky