Friday, November 03, 2000, 10:21:39 AM, you wrote:
> Ok..that sounds great. Now, how about an XSL example? :)
Take a look at http://www.xmlinfo.com/uses/ at the bottom.. a list of sites that
use XML behind the scenes and then some sort of transformation to produce HTML
(possibly using XSLT.. but not always).
The xmlinfo.com site itself also uses XML and XSL to produce the pages you see.
> Does every page
> need to have its own XSL, or can I still build JSP pages the way I do now,
> which is, every JSP page includes a HEADER.INC file, and a FOOTER.INC. In
> the header include, I have lots of scriplet code that displays a
> "consistent" graphical menu bar at the top of every page, with the ability
> to change the actual image depending on any number of circumstances. Also,
> the login menu, some dynamic text and so on is displayed based on any number
> of circumstances as well. Ideally, what I am after is the ability to allow
> the end user to "customize" the way the site looks. Instead of the menu bar
> at top, maybe they want it on the side. So the XSL would basically somehow
> use two frames, one on the left and the big one on the right for content.
> Maybe they want the footer on the bottom to never disappear, the menu bar at
> the top to never disappear, and the content in the middle to be scrollable,
> so that no matter what page they go to, the top and bottom stuff never
> changes..only the content. Some may like to see their name displayed, some
> may not. Some may want their name in RED ARIAL, some may want it in yellow
> Times, and so on. I know a number of these things can be done pretty easily
> in JSP (I have done it), but I would like the ability to use XSLT to also
> render WML and HTML, as well as "text" only all with the same given data. I
> have seen a site use XSL/XSLT for just this purpose.
XSL has the ability to include other XSL files... other XML files of data etc at
runtime.. so you can re-use as much as you want for each page. If you create all
of your pages in an extremely consistent way... so that the XML structure you
pass to the XSL always uses the same DTD.. .then realistically you can get away
with a single XSL file. In practice I find this impractical.. each page displays
different information in different ways...
The number one reason to go this route is the separation of data and
presentation. The JSP/XML _ONLY_ should hold data for the page to be displayed
an not any presentation... the better the separation... the cleaner the code on
the XML and XSL side. The XSL does all the presentation pulling in data from the
XML tree when required...
Once you have a clean division... then things like internationalization,
localization, multiple-platform support, etc.. become a lot easier.
And what is cool, something that is not immediately obvious, is that you don't
have to use every piece of information that resides in the XML structure. So
then output to a PDA, i-mode, Navigator 1.0, IE 5.5,... whatever becomes just a
matter of tweaking your XSL... or using a different XSL altogether.
Someone posted a nice JSP taglib a while back to do just that. Detect at runtime
which browser/platform/device the person is accessing your site with (depending
on what you support) and then setting the XSL file within the JSP/XML
appropriately.
> Incidentally..do you have any example URLs that I can look at..to see what
> XSL output has done for your site?
Not of our site right now... we don't have any sites that use XML/XSL deployed
for public viewing yet. Still in development.
Take a look at http://www.xmlinfo.com/ (as mentioned above)... some good
pointers. I read the XSL-List at mulberrytech.com religiously... an excellent
set of minds in that mailing list.
> Thanks.
You're welcome.
Dylan Parker