473,472 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using multiple stylesheets with 1 xml file

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!
Jul 20 '05 #1
4 3770
On 20 Nov 2003 06:50:54 -0800, st***********@ams.com (steve) wrote:
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)

--
Die Gotterspammerung - Junkmail of the Gods
Jul 20 '05 #2
thanks - that was extremely helpful..i'm surprise that something this
"basic" is so difficult!
Andy Dingley <di*****@codesmiths.com> wrote in message news:<fm********************************@4ax.com>. ..
On 20 Nov 2003 06:50:54 -0800, st***********@ams.com (steve) wrote:
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)

Jul 20 '05 #3
In article <f4**************************@posting.google.com >,
st***********@ams.com (steve) wrote:
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.
Jul 20 '05 #4
st***********@ams.com (steve) wrote in message news:<f4**************************@posting.google. com>...
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!
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jacqui or (maybe) Pete | last post by:
Having just answered a question about multiple linked stylesheets, I thought I'd have a look at browser support. There's a quick test page here: http://www.porjes.com/ms/ I wrote it...
4
by: Carolyn Marenger | last post by:
Hey everyone, I am looking for your thoughts and opinions. Is it preferable to have one css file containing all the style information or break it up into multiple imported files for different...
5
by: Don G | last post by:
Is it possible to link multiple stylesheets to a single web page? I have an overall stylesheet for my entire site, but there are a few pages with a minor differences. I originally had these as...
3
by: David Blickstein | last post by:
Hi, I have a Schema and a number of different XSLT stylesheets to translate to different things. One stylesheet translates it to HTML. I'd like to generate the XML files such that when loaded...
1
by: PK9 | last post by:
I'm building a windows app using C#. The goal is to merge portions of multiple xml files into one. I currently have an .xsl stylesheet that pulls in the required sections of multiple xml files...
5
by: steve_marjoribanks | last post by:
This isn't strictly an XML problem but I thought someone might be able to help! As part of my degree I am working on a new data format for use in the geotechnical engineering domain. The data...
3
by: spolsky | last post by:
hi, it is possible to apply multiple styles as shown in the following example. <STYLE TYPE="text/css"><!-- BODY { background-color:salmon; } P { margin-left:20px; } .clsCode {...
8
by: mscertified | last post by:
I have two stylesheet files, one is a standard file and one a custon file. They have no classnames in common. How do I specify that my page use both stylesheets? I tried Help and as usual could...
13
by: Toby Newman | last post by:
I started learning XML on Monday. I have an XML file and have written an XSL file to render it to HTML for formatted viewing in a browser. I'd like to create a second alternative view of the...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.