XSLT <xsl:namespace-alias> element
Definition and Usage
The <xsl:namespace-alias> element is used to replace the namespace in the stylesheet with a different namespace in the output, in other words, to use other prefixes to replace the prefixes associated with the given namespace.
Note:<xsl:namespace-alias> is a top-level element (top-level element) and must be a child element of <xsl:stylesheet> or <xsl:transform>.
Sometimes, an XSLT file generates another XSLT. This brings problems for the namespace, because there is no clear way to declare two prefixes for the same namespace, and the processor will not treat the two prefixes as the same namespace and perform operations. The <xsl:namespace-alias> command can allocate a transition namespace to the alternate prefix, apply the stylesheet, and then map the alternate namespace to the XSLT namespace.
Although the generation of files from XSL to XSL is the main purpose of this command, it is not the only purpose. This command can be used at any place of namespace conflict (for example, xsi: schema data type namespace).
syntax
<xsl:namespace-alias stylesheet-prefix="prefix|#default" result-prefix="prefix|"#default"/>
attribute
attribute | value | description |
---|---|---|
stylesheet-prefix |
|
Required. Specify the namespace you wish to change. |
result-prefix |
|
Required. Specify the expected namespace for the output. |
Instance
Example 1
Prefix wxsl is converted to prefix xsl in the output:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wxsl="http://www.codew3c.com/w3style.xsl" <xsl:namespace-alias stylesheet-prefix="wxsl" result-prefix="xsl"/> <xsl:template match="/"> <wxsl:stylesheet> <xsl:apply-templates/> </wxsl:stylesheet> </xsl:template> </xsl:stylesheet>