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, use another prefix to replace the prefix 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, XSLT files generate another XSLT. This brings a problem with namespaces 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 temporary namespace to the alternate prefix, apply the stylesheet, and then map the alternate namespace to the XSLT namespace.
Although file generation from XSL to XSL is the main purpose of this command, it is not the only purpose. This command can be used anywhere there is a 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 |
|
Mandatory. Specifies the namespace you want to change. |
result-prefix |
|
Mandatory. Sets the expected namespace for the output. |
Example
Example 1
Prefix wxsl na a bawa kama prefix xsl: a bayan
<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>