XSLT provides an effective and elegant solution to many typical transformation problems. Transformation of data is often thought of as something that a program must do. But as XSLT has demonstrated, that is not always true. An XSLT stylesheet looks like XML and so I have a hard time considering it a programming language like C or Java. Nevertheless, XSLT is capable of modifying an XML tree. It can act on input data and produce different outputs. There are cases, however, where limitations of XSLT is evident. Unlike a typical programming language, XSLT has limited number of data types. It also has a limited number of built-in functions. So as a design issue, one has to consider what types of transformations are natural for XSLT and what transformations require a traditional programming language. There is an alternative to his approach and that is to use XSLT extensions.
Extension elements and functions, allow you to mix XSLT with a programming language like Java or a scripting language like JavaScript. You now have a mixed model, which allows you to use both XSLT and the flexibility of a conventional programming language under one umbrella. The Xalan processor from Apache (http://xml.apache.org/xalan/index.html) provides a full implementation of such extensions.
Extensions come in two flavors. Extension elements are valid XML elements that perform specific actions. They are similar to how tag library elements work in JSP. The element looks like XML making it easy to use for XSLT developers, but its underlying implementation can be in Java or other languages. The Redirect extension is an example that ships with Xalan. It contains three extension elements:
Another way of incorporating extensions into XSLT is through extension functions. XPath already supports a number of functions. Extension functions augment those by using a consistent syntax. Xalan uses the Bean Scripting Framework (BSF) and supports extensions in Java and JavaScript. Extensions will have their own namespace (lxslt). The component and script elements contain the implementation details. In case of Java, there is a src attribute that identifies the Java class. From the XSLT developer point of view, extension functions look like any other XPath function with the exception of a prefix.
If you have been skeptical about XSLT due to some of its limitations, you should seriously consider XSLT extensions. They provide a nice framework for using conventional programming tasks and incorporating business logic into transformations done by XSLT. Performance, most likely remain an issue and any time two disparate programming models are combined, careful attention should be give to design details to assure interoperability, reliability and ease of use.
Piroz Mohseni