Coming up with effective XSLT scripts is not a trivial task specially when complex transformations are involved and the source document has a complicated structure. For certain transformations XSLT offers more than one solution further complicating the task of writing XSLT scripts as issues like performance and efficiency need to be considered. Fundamentally, the problem of transformation is not anything new. For decades, tools have been transforming data from one format to another. One of the areas where such transformations have been common is databases where data mapping tools have been helping designers visualize the changes. After some fine-tuning, these tools are able to generate the necessary scripts.
Since XSLT transformations address the same fundamental issue (although the data is presumed to be in XML format), it was just a matter of time before new tools brought about the same visual approach. Tools like XML Spy from Altova (www.xmlspy.com), and Stylus from Excelon (www.exceloncorp.com) are some examples, which provide an XML editing environment along with support for XSLT.
Another tool that exclusively focuses on XSLT transformations is XSLerator from IBM Alphaworks. It can be downloaded from http://www.alphaworks.ibm.com/tech/xslerator. Although it is still under development and it doesn't support the latest version of XSLT specification, I found the tool quite practical. You actually need very little knowledge of XSLT syntax to use the tool. You start be importing a source file and a target file. These could be raw XML files or generated by connecting to a database and extracting the appropriate fields. The tool uses JDBC to connect to a data source. The tool will generate a tree structure representing the structure of both the source and target data. The "transformation" is then achieved by visually creating a series of mappings. A mapping consists of a source element, a conversion function and a target element.
The default mapping is to simply copy the source into target. You have a number of functions such as concat(), translate(), substring(), contains(), min(), and max(). You can also use XSLT constructs for conditions, loops (for-each) and sorting. As you complete the mapping you can see the XSLT script that is being constructed allowing you to experiment on the fly with various approaches. Upon completion, you can generate the entire XSLT script and execute the transformation from within the tool. It uses Apache Xalan's implementation of XSLT. The tool ships with examples and a complete tutorial.
If your main usage of XSLT is to transform XML into HTML or XHTML for browser viewing, XSLerate may not be the right tool for you because it doesn't treat HTML in any special way. On the other hand, I think XSLerate would be a great tool for typical B2B applications where documents from one application need to be mapped into another structure to be consumed by the receiving application. Typically in these cases, the source and target structures are known and the problem is coming up with the "right" XSLT script. XSLerate provides a visual environment to capture the appropriate mapping and then generates the XSLT script.
About the Author
Piroz Mohseni is president of Bita Technologies, focusing on business improvement through the effective use of technology. His areas of interest include enterprise Java, XML, and e-commerce applications.