[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Displaying one section of XML file at a time


Subject: Re: [xsl] Displaying one section of XML file at a time
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Thu, 9 Mar 2006 14:42:45 -0600

> My transformation environment --- sending XML with a
> stylesheet PI to the browser

Not exactly my favorite way to do it, esp not for beginners.  Ah well, ;).


> My XML file has three sections of data, which I
> transform into three tables using XSL style sheet:
>
> Table 1
> Table 2
> Table 3
>
> I want to display Table 1 by default and let the user
> choose to view that data in next two tables by
> clicking Table 2 or Table 3.
> Is this possible to do by adding JavaScript in my XSL
> style sheet?

Hmmm, there's really a couple of ways to take this question.

1) You can create a html page via xslt that has all three tables.  You
would then use the css display/javascript trick as you would in any
other html page.  Some googling of javascript, css, and display should
get you that info.

2) If you had a server-side transform it might be easier to pass it in
via a parameter in the url which in turn is used as a parameter for
the stylesheet return an html page that only contains the necessary
table.

3)  That said, there are some browser-specific ways to do this I
think.  If I recall correctly, there's a way in IE to read in a
foreign xml document, transform it via xslt, and then dump the results
into a window.  You could then pretty easily do something similar to
option two but on the client-side.  Notice it would be browser
dependent (not just if it was IE or not, but what parser/processor
that  version of IE is using).  Notice this is still not an "XSLT
page".  It would be showing an HTML page that has the capability to
use javascript to replace it's own contents with the results of a
transformation applied to the source XML.

Notice in all the cases XSLT is used to transform XML content into an
html page.  To it javascript is just more text to generate.  The
user's browser is manipulating the html results of the transformation.
 If you really need to use client-side transformation, you might want
to either do things similarily to method 1 or research into systems
like Sarissa (don't know much of the details there).

In order to pick what table would be outputted, you'll pass in a
parameter to the stylesheet.  Poking around the FAQ and the archives
of this list should give you some ideas on how parameters work.

My usual recommendation for people is not to learn XSLT on the
browser.  This isn't necessarily condemning ever using the browser
transforms, but it seems difficult for newbies to understand what is
happening at what point when they do use browsers.  It also makes
debugging rather painful.


Jon Gorman








> If yes, would someone be kind enough to send me an
> example, or point me to one?
>
> Thanks,
> Gowri
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com


Current Thread
Keywords