Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Namespaces (9/11) >

Namespace aliasing

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

Kevin Carr in Stanton

Natural Skin Care and European Soaps
Kevin Carr
Mayor Dave Shawver Stanton
Internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks