Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
As XSLT stylesheets are formulated in XML and the result of an XSLT transformation can be any
XML document, wouldn't it be interesting to generate stylesheets on the fly using another
XSLT stylesheet? But how would you do that? How do you output an xsl:template
element without causing syntax errors in the first stylesheet? After all, a template cannot
hold another template.
This is where the slightly obscure element xsl:namespace-alias comes to the rescue.
It allows us to use elements of a namespace A in our stylesheet, but just before
the result tree is written to the result document, all nodes with namespace a are
changed to another namespace (B).
When you try to generate a stylesheet, you would just create elements using a dummy namespace
(dummy:template). Then, using xsl:namespace-alias, we wouls specify the in the
output, this dummy namespace should be converted to the XSLT namespace
(http://www.w3.org/1999/XSL/Transform).
In this example, we generate a stylesheet that can transform a piece of code like
2231971
to something like
where the names of the months come from the source document of the first transformation. This
allows you to keep even some of the content bits that appear inside the stylesheet in a separate
XML document, merging them as you need them. In this case, we used the spanish content, but we
may have many.
Note: You can now download the full content of the XPath reference, the XSLT reference and the
DOM reference in one PDF document. This document contains the implementation tables, internal
links to navigate through the references, a full linked table of contents. You can use free text
search through the whole reference or print as a nicely formatted document.
Download here...