Look at the different patterns of usage of XSLT when generating code and/or scripts.
- Cocoon XSP
- Structured XML language for generating Java code
- Separates code details (optimisation, API) from applications
- Modular
- Cocoon Sitemap
- A little language
- Create declarative languages for working with procedural code
- Graphotron
- Separates declarative language from details of implementation
- Therefore can be used to generate output in a variety of languages
- Can share common framework
- Schematron
- XSLT itself may be used as an implementation language; functionally complete
- "Meta-stylesheets"
- Tricks for working with these, e.g. adding namespaces
XSP is structured language(?); Graphotron is declarative Sitemap generates Java; Graphotron generates multiple outputs XSP/Graphotron uses 'conventional' language?; Schematron functional
Little Languages can be simpler to understand
XSLT is good as a templating language not only for presentation but also code generation
There are other approaches, e.g. XDoclet which generates code from embedded comments.
There's a potential equivalent in XML: generating code from XML Schema annotations. Probably only useful for validation purposes, although perhaps can type annotation for different languages?
Meta-stylesheets (The Collider) are best way to handle UI templating; other techniques are limited in their capability, e.g. handling recursion cleanly.
Working with meta-stylesheets in Cocoon
is something I wrote up on the Cocoon Wiki. It's actually an implementation of the The Collider pattern but I didn't stress that angle there.