Topic: XSLT styleswitching (Page 1 of 1) Pages that link to <a href="" title="Pages that link to Topic: XSLT styleswitching (Page 1 of 1)" rel="nofollow" >Topic: XSLT styleswitching <span class="small">(Page 1 of 1)</span>\

Neurotic (0) Inmate
Newly admitted

Insane since: Aug 2004

IP logged posted posted 08-29-2004 21:39 Edit Quote

Is there a way of switching XsLT styles in a similar way that Sowdon's styleswitcher does for css? If possible, I would like to port the user choices I have on to pages controlled by xslt.


Paranoid (IV) Inmate

From: Brisbane, Australia
Insane since: Jan 2003

IP logged posted posted 08-29-2004 21:58 Edit Quote

Not that I'm aware of, and given the way you declare XSLT I highly doubt it.

The first problem I forsee is that few browsers support XSLT. Usually, you use XSLT on the server to transform your XML document into (X)HTML (or something like an RSS feed, which doesn't require styling anyways). In such a case, it's impossible to alter this dynamically without reloading the page. If you use the browser to do the XSLT transformations then it *might* be possible but I highly doubt it.

Although, If this is for a website and all you want to change is the style, then you should just use CSS. THat's what it's designed for. XSLT is usually overkill for basic web stuff, unless you're dealing with data centric web apps that need to comunicate with a range of user agents or output mediums, I can't see why you'd really want to use XSLT (or just XSL) in the first place.

Obsessive-Compulsive (I) Inmate

Insane since: Aug 2004

IP logged posted posted 08-29-2004 23:45 Edit Quote

thanks, Cameron. The skin change I want is for a fairly complicated xhtml+smil output and thus xsl(t)is being favoured. Thus, the only browser support is IE5.5 or above but that is ok in the sense that what we achieve is not supported by other browsers but we also output a pure smil version for realplayer, etc. For reasons of accessibility, our audience (university students) needs to be able to change background and font colour on only a section of the output. I was hoping that somebody had already written and tested some javascript to do this at the browser level.

For various reasons it would not be suitable to invoke a server level solution.

Paranoid (IV) Inmate

Insane since: Jul 2002

IP logged posted posted 10-20-2004 02:59 Edit Quote

You -could- do this client-side via the XMLHTTP object etc. (just recreate the XSLT object and load a new stylesheet into it) - but this would only work on IE 5.x/win32 and Mozilla 1-point-something. I don't think Safari (1.2 currently out at time of writing) has a native Javascript XSLT processor.

Something like this would work for the former however (although server-side is really the way to go I think):

var xmlFile = "file.xml";
var xslFile = "file.xsl";

// IE method

var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;

var xsl = new ActiveXObject("Microsoft.XMLDOM");
xsl.async = false;

var result = (xml.transformNode(xsl));

// ---------

// Mozilla etc.

var xsl;
var xslt = new XSLTProcessor();

var xmlhttp = new XMLHttpRequest();"GET", xslFile, false);

xsl = xmlhttp.responseXML;

xmlhttp = new XMLHttpRequest();"GET", xmlFile, false);

var xmlSource = xmlhttp.responseXML;

var resultDocument = xslt.transformToDocument(xmlSource);

(Edited by Scott on 10-20-2004 03:00)

Bipolar (III) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

IP logged posted posted 10-20-2004 03:16 Edit Quote

Well, it's kinda hard to do a style switcher for XSLT - XSLT isn't a style sheet language, it's a transformation sheet language. It works by changing the document into another structure. XSLT transforms a source document into another generated document. The DOM works on this generated document, not the source document, and thus you can't use the DOM for changing the transformation sheet. At least, I don't think there is a good API for doing it. I'd hunt around and before I say anything more final, though, there might be APIs that I have overlooked.

As a second note, neither Opera nor Safari suppports XSLT in their current versions, though Safari will probably have XSLT support in it's 2.0 version.

var Liorean = {
prototype: XHTMLGuru.prototype,
abode: "",
profile: ""};

Post Reply
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
Your Text:
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu