Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

XSL gives your XML some style

Use XSL and servlets to style your XML data

  • Print
  • Feedback

Page 7 of 7

Another handy XSL use: take a java.sql.Result set and turn it into a simple XML document in which the name of the query is the root node and each row in the result table is an element in our XML document. Then the subelements of that element are the columns and values from that row. Taking that plain, well-formed XML document, we can simply apply XSL to it, creating an XML document that conforms to a desired schema. That would be nice for EDI (Electronic Data Interface) or anything else where you need to extract data from a relational database such as XML.

A word on performance: the XSLProcessor runs very fast; it completes transformations in subsecond time. Performance degrades as the stylesheet does more processing or more complex processing. The input XML has to get pretty big -- over 100 KB -- before you will notice a significant decrease in performance.

In conclusion, XSL provides an easy way to change XML to HTML. But it can do much more than that. The extension mechanism gives added functionality to the basics of XSL. Using servlets to process your XSL will help you keep your content and presentation separate.

Read more about Core Java in JavaWorld's Core Java section.

  • Print
  • Feedback

Resources