Bryce Harrington provò:
Well, last year I'd played with a system (Zope) that did its templating language in XML, resulting in a cumbersome pseudo-XML-in-XML system that was truly irritating. There were a couple issues in particular I found irritating. The first was that it attempted to represent programming logic with XML, which just plain doesn't fit. I.e., something like this:
<if condition="1"> <p>Foo</p> <else> <b>Bar</b> </if>
The second was that mixing the <>'s for the template language with the <> from the data got extremely confusing. That's one of the reasons I like Template::Toolkit - since the templating commands are enclosed in [% %] it distinguishes it very clearly from the HTML or XML data.
Similarly, with templating you are often doing variable substitutions. I.e., something like:
<rect height="<var name="h"/>"/>
You can see how visually cluttered that looks having XML inside XML. Using a distinctly non-XML templating syntax reads easier:
<rect height="[% h %]"/>
I've looked at some templating system for my site and my requirements were thath the template should be a valid XHTML document and that it should be quite easy to integrate with real code. The best templating system that I've currently found is Kid (written in python).
I think that reusing a templating system thought for XML documents is a good idea...
Hmm. I've seen XSLT used to good effect for transforming data from one XML format to another (which would be very cool to be able to do in Inkscape directly), but haven't seen them used quite so much for templating applications. For example, if you're doing a database pull and need to display 20 records, with some logic to display certain icons or colors depending on properties within the data stream; you have a data structure that is essentially an array of hashes, and use the template to represent what they should look like in HTML, XML, or whatever.
XSLT is defined as a tree to tree transformation, so it needs an XML tree to represent the database records. This is the main limit (for my use) of XSLT: it is difficult to integrate it with real code. For templating XSLT is very good, except it has a steep learning curve.