Next / Previous / Contents / TCC Help System / NM Tech homepage

11.8. <xsl:namespace-alias>: Assign a prefix to a namespace

This is a pretty obscure feature. It has only one use: writing an XSLT script that generates another XSLT script.

Since normally any tag whose name starts with xsl: is processed, we have to provide a way to output a tag in the xsl: namespace without processing it. The way we do this involves two steps:

  1. You must declare two different prefixes for the xsl: namespace in the attributes of the <xsl:stylesheet> tag. One prefix is declared as xsl:; you will use this namespace for the elements that you want to process as part of your stylesheet. The other prefix is used to refer to the elements that you want to write to the output document.

  2. You must provide a top-level <xsl:namespace-alias> element with a stylesheet-prefix attribute whose value is the other prefix (besides xsl:), and whose result-prefix attribute is "xsl".

For example, suppose your stylesheet starts this way:

    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:out-xsl=""http://www.w3.org/1999/XSL/Transform">

      <xsl:output method="xml"/>
      <xsl:namespace-alias stylesheet-prefix="out-xsl"
        result-prefix="xsl"/>
      ...

then elements in your stylesheet with namespace xsl: will be processed, and elements with namespace out-xsl: will be written to the output document.