In advanced programming, e.g. when a stylesheet is generated by another stylesheet, it is some times useful to use aliases for namespaces to be outputed.
Element xsl:namespace-alias is very useful in such a case. In the example the first alias moves element from "oooooo" namespace to "rrrrrr" namespace and so we have r:yyy in the output. The second alias moves unprefixed element in the stylesheet to the "ssssss" namespace and so we have s:ppp. The third alias moves elements from "zzzzzz" namespace to default result namespace, in this case the element xxx is in the null namespace.
|
XSLT
<xsl:stylesheet xmlns:o="oooooo" xmlns:r="rrrrrr" xmlns:s="ssssss" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:z="zzzzzz" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:namespace-alias stylesheet-prefix="o" result-prefix="r"/> <xsl:namespace-alias stylesheet-prefix="#default" result-prefix="s"/> <xsl:namespace-alias stylesheet-prefix="z" result-prefix="#default"/> <xsl:template match="/aaa"> <z:xxx xsl:exclude-result-prefixes="#all"> <o:yyy/> <ppp/> </z:xxx> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa/> |
Output
<xxx xmlns:r="rrrrrr" xmlns:s="ssssss"> <r:yyy/> <s:ppp/> </xxx> |
| Previous chapter: | Multiple Outputs |
| Next chapter: | Keys |
| Previous page: | Removal of unwanted namespace declarations |
| Next page: | Namespace creation |