using multiple stylesheets with 1 xml file

S

steve

I'm new to XML, so pardon the stupid question.

I've looked thru several books with not luck. All I want to do is
associate one xml file with multiple xsl stylesheets. For example, if
the user clicks on Button A, I want to use xsl stylesheeet A to
display the xml data in a browser. If he clicks button B, then I want
to use stylesheet B. I would think that this would be a very common
thing to do, but maybe i'm missing something big.

Is there an easy way to do this? Do I have to use (learn) Javascript
or something? does someone have an example?

your input is appreciated!
 
A

Andy Dingley

All I want to do is
associate one xml file with multiple xsl stylesheets.

This is easy. Getting it to do something useful is harder !

You can "associate" multiple stylesheets by using multiple PI's (the
<?xml-stylesheet ... alternate="yes" ?> business)
http://www.w3.org/TR/xml-stylesheet/

Small problem with this is that you can indicate the default with
alternate="no" (or omitting it) but there's no mechanism to indicate
precedence or other bindings for alternates. The "media" attribute
might be adequate for you.


A larger problem is that this association does not _cause_ the
stylesheet to be processed. That's the task of the stylesheet
processor, which is an application-dependent task that's outside the
scope of the W3C standards.

If you're on your own web server, then it's pretty easy. parse the
PI's at the top, invoke the processor accordingly. Write your own
rules for selecting which one to choose, and just invoke the processor
accordingly.

On the client-side browser, then IE (and some others) now process XML
according to a default stylesheet (but watch out for a "default"
choice that's merely the first in the list, ignoring the alternate
attribute).

If you want alternates to be processed usefully on the client, then
you're into writing some JavaScript. You may find a "data island"
approach useful here, loading the page as static HTML with embedded
XML, then processing it and writing it into a <div>, rather than
processing the whole XML document into a single output page (which can
then be hard to retrieve the other PI's)
 
S

steve

thanks - that was extremely helpful..i'm surprise that something this
"basic" is so difficult!
 
F

fips152

I'm new to XML, so pardon the stupid question.

I've looked thru several books with not luck. All I want to do is
associate one xml file with multiple xsl stylesheets. For example, if
the user clicks on Button A, I want to use xsl stylesheeet A to
display the xml data in a browser. If he clicks button B, then I want
to use stylesheet B. I would think that this would be a very common
thing to do, but maybe i'm missing something big.

Is there an easy way to do this? Do I have to use (learn) Javascript
or something? does someone have an example?

your input is appreciated!


Using some very simple CGI to change one line of
text, "http://www.csszengarden.com/" is a nice
demo of changing the CSS style sheeet.
 
B

Baldo

Is there an easy way to do this? Do I have to use (learn) Javascript
or something? does someone have an example?

u can use a TOMCAT + jsp + passing variable throught link

quite easy to say, but very hard to do!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top