Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh


Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do we access the XSLT to give HTML from XML?
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yogesh Deshmukh:
How do we access the XSLT to give HTML from XML?

What do you mean exactly? If I'd interpret your question literally the answer would be "using a text editor"
Oh well, this is as good a place as any to try a summary; given that this forum is the subject of this week's giveaway there may actually be people reading it to the end
First, XSL versus XSL Transformations (XSLT). XSLT deals with transformations of one XML tree (parsed document) into the other. It is great for XML-XML, XML-HTML, XML-WML transformations etc.
To this transformation facility, XSL adds Formatting Objects (FO). They convert the output tree into an arbitrary output format, and are used e.g. for XML-PDF transformations (see the Cocoon framework for a fleshed out example of this).
But, you wanted to transform XML into HTML and are happy with XSLT. To give the flavour, take the following example XML file.

Suppose you wanted to transfom it into the following HTML

Then you could use the following XSL transformation:

You see that in this basic form, there is very little to it. You iterate through the XML file with for-each; you retrieve values from it using value-of.
The approach illustrated here pulls the values from the XML file. The template (HTML file, in this case) is in the driving seat. But XSLT is actually a pattern-matching language which allows you to let the XML file sit in the driving seat, if you prefer; in that case you specify a number of templates and patterns and the XSLT processor applies the templates which match the structure of your XML file. In fact, in the XSLT file above I'm implictly matching the pattern "/", the root of the XML document.
See the W3C for the formal standards, the XSL FAQ for your basic questions. XSL(T) processors: the Apache XML project, XT, Saxon. The #1 mailing list on XSL is this one.
Last but not least, if you prefer your information thorough, solid and densely packed, and G. Ken Holman is speaking at a conference near you, run, don't walk. His were the best two hours I ever spent at a conference, ever.
- Peter
PS. I did a little, lightweight 5-page write-up about XML and XSL half a year ago from which I cut and pasted much of the above. Not sure how useful it would be to anyone but I'd be willing it to e-mail it to you (Word or HTML).

[This message has been edited by Peter den Haan (edited March 13, 2001).]
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic