Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   using multiple stylesheets with 1 xml file (http://www.velocityreviews.com/forums/t166094-using-multiple-stylesheets-with-1-xml-file.html)

steve 11-20-2003 02:50 PM

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!

Andy Dingley 11-21-2003 09:55 AM

Re: using multiple stylesheets with 1 xml file
 
On 20 Nov 2003 06:50:54 -0800, steve.lescure@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

steve 11-24-2003 07:21 PM

Re: using multiple stylesheets with 1 xml file
 
thanks - that was extremely helpful..i'm surprise that something this
"basic" is so difficult!


Andy Dingley <dingbat@codesmiths.com> wrote in message news:<fmnrrv8r9fbgeqdmm2agap974h7qrcv9s1@4ax.com>. ..
> On 20 Nov 2003 06:50:54 -0800, steve.lescure@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)


fips152 11-26-2003 10:11 PM

Re: using multiple stylesheets with 1 xml file
 
In article <f489a8be.0311200650.4c6c44da@posting.google.com >,
steve.lescure@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.

Baldo 12-03-2003 10:03 AM

Re: using multiple stylesheets with 1 xml file
 
steve.lescure@ams.com (steve) wrote in message news:<f489a8be.0311200650.4c6c44da@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!


All times are GMT. The time now is 01:09 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.