Tips and Tricks: XSL is Your Friend with XML

October 2007

Situation:

You have multiple customers who want similar data displayed in vastly different situations. The ability to quickly adapt display as business rules change is a must. The potential pitfall is maintaining multiple page files for each customer with essentially the same functionality.

Solution:

Create a single backend XML generator to collect the data and then run the output through XSL transformation. Allow configuration to control which *.xsl is used for a given customer.

Tips and Tricks:

XSL has many tools to allow you to do anything from dynamically generating entire pages on the fly to page fragments for a specific section.

The conditional tags such as and have powerful selection abilities much like any 3GL programming language.  Written correctly they can drive an entire website.  Much more simply, they can help configure your application to display different data for different customers.

For example say we have the following XML data:

  1. <root>
  2. <customer>
  3. <url>http://www.rossgroupinc.com</url>
  4. </customer>
  5. </root>

Using the following XSL we can select a configuration for a given customer:

When the condition matches, as it does in this case, the statements inside of the if block will be executed.  This can be anything from a simple “yes” or “no” condition to another template.  Any tag in HTML can be dynamically generated in XSL.  For example, below is the XSL for a dynamically generated link:

If you need more information, contact Gary Codeluppi at 937-431-1026 x123 or visit the Ross Group Inc web site at www.rossgroupinc.com.

Comments (0)Add Comment
Write comment
 
 
smaller | bigger
 

busy
search | login