Note: this is an historical post, which I originally wrote in 2008. I’ve pulled it from my archives and am reposting it today without changes. – Julie 3/30/2020
In case you’re pondering whether or not to shift your docs to XML, here is another reason to do so.
One great feature of XML is the ability to incorporate some programming functionality into your docs. For instance, you can set up your XSL file to include some if..then and loop processing. You can set up attributes in such a way as to facilitate this processing.
One example is an attribute for, say, a “vegetable” element. The XSL file could contain a choose and when instruction to review the attribute, and if the attribute is “potato,” then display a specific picture of a potato.
For loop processing, you can use the for-each instruction. This is particularly useful for tables. Instead of building a table in HTML with content hard-coded in each row, you can build an empty table in your XSL file along with for-each instructions to populate it with content from your XML file. For example, let’s go back to the vegetable content. Imagine that you have two vegetables: potato and lettuce. For each of those, you have two types. For potato, it could be russet and red; for lettuce, it could be romaine and iceberg.
When you use for-each, you can essentially say (in this case): take the first vegetable and its two types (the nested elements), and put it all in one table row. Then go back and select the next vegetable and types, and put it in the next row. This continues until all the elements (potato, lettuce, etc.) have been transferred to the HTML table. If content changes are needed afterward, you can just update the XML. The HTML is part of the XSL file, so wouldn’t be changed.
In any case, more options are available to set up your docs with more flexibility and processing features when you use XML.