Let's say that you have a block of text in a file and you need to add a paragraph tag around it. Thus, you want to add <p> at the beginning and </p> at the end, and put the result in a new file. Sounds easy right? Of course. Since we have so many great new technologies at our disposal, here's one way I've seen it done recently:
- Set up a Java Servlet engine on a Web server somewhere. The process begins when a user loads a specific URL in a browser.
- The code starts by reading a configuration file which lists classes to be used during the process which are later dynamically instantiated as needed.
- One such class parses the text file into an abstract in-memory object.
- Another class takes the abstract object and serializes it into XML.
- The XML is parsed.
- A second configuration file is loaded which contains a reference to the location of an XSLT file.
- The XSLT file is loaded and parsed.
- The XML is translated using the XSLT template.
- The resulting content is then serialized and saved into a file.
- That file is copied into another directory.
We've come a long way since the early days of computing. I mean, thirty years ago we would have done that task using something extremely cryptic such as this:
(echo '<p>'; cat file.in; echo '</p>') > file.out
Or, unfortunate programmers would have had to resort to using a couple of lines of sed. Thank goodness we don't have to use these old technologies any more, now that we have all these great new advances.