Topic: XSLT styleswitching (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23117" 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>\

 
kitamz
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Aug 2004

posted posted 08-29-2004 21:39

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 http://smirk.herts.ac.uk to pages controlled by xslt.

thanks

Cameron
Paranoid (IV) Inmate

From: Brisbane, Australia
Insane since: Jan 2003

posted posted 08-29-2004 21:58

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.

kitamz
Obsessive-Compulsive (I) Inmate

From:
Insane since: Aug 2004

posted posted 08-29-2004 23:45

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.

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

posted posted 10-20-2004 02:59

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):

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

// IE method

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

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

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

// ---------

// Mozilla etc.

var xsl;
var xslt = new XSLTProcessor();

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", xslFile, false);
xmlhttp.send(null);

xsl = xmlhttp.responseXML;
xslt.importStylesheet(xsl);

xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", xmlFile, false);
xmlhttp.send(null);

var xmlSource = xmlhttp.responseXML;

var resultDocument = xslt.transformToDocument(xmlSource);



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

liorean
Bipolar (III) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

posted posted 10-20-2004 03:16

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 http://unstable.elemental.com/mozilla and http://msdn.microsoft.com/ 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: "http://web-graphics.com/",
profile: "http://codingforums.com/member.php?u=5798"};



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu