Next, in Part II we saw using Xalan from a Java program, how to convert XML files to plain text file. In this third and final part III of the series, we'll closely look at the stylesheet file used to do the conversion. The above file, example.xsl is the core to actual transformation of an XML document to a text document. All XSL files are standard XML documents. The first line in example.xsl, simply defines the use of XSL language, it's version and namespace reference.
Next line specifies the desired output method.
The following line tells the transformation engine to trim all leading and trailing spaces as they are not needed in the output. The sub-elements under template match tags specify what action needs to be done to those matching entries. The next four lines insert a single space followed by the middle initial. Since the next transformation lines are really similar to one we just saw, we'll not go into details. Let's now see what changes we need to make in above stylesheet to get the result in HTML format rather than plain text.