XSLT <xsl:namespace-alias> element
Definition and usage
<xsl:namespace-alias> element is used to replace the namespace in the stylesheet with a different namespace in the output, in other words, using 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 creates a problem for the namespace, because there is no clear way to declare two prefixes for the same namespace, and the processor will not treat two prefixes as the same namespace and operate on them. The <xsl:namespace-alias> command can assign a transition namespace to an alternative prefix, apply the stylesheet, and then map the alternative namespace to the XSLT namespace.
Although the main purpose of generating XSL to XSL files is the main use of this command, it is not the only use. This command can be used in any namespace conflict (for example, xsi: schema data type namespace).
grammar
<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>