Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project


   







ELEMENT:  xsl:namespace-alias

<xsl:namespace-alias
  stylesheet-prefix="prefix"
  result-prefix="prefix"
/>

 
The xsl:namespace-alias element is used to replace a namespace (prefix) in a stylesheet with a different namespace (prefix) for use in the output. There must be one xsl:namespace-alias element for each namespace you wish to change. In general, the primary use for this element is to convert non-XSLT elements (literal result elements) into XSLT elements for display in the output. The literal result elements are said to be mapped to the XSLT namespace.
 
A xsl:namespace-alias element can only be a child of the xsl:stylesheet or the xsl:transform elements.
 
This is a self-closing element and it cannot contain any child elements or any content.
 
stylesheet-prefix
 
The mandatory stylesheet-prefix attribute is the namespace (prefix) that you wish to change. If there is more than one xsl:namespace-alias element that have the same value for the stylesheet-prefix attribute, the one with the highest import precedence is selected. (If there is a tie on import precedence, an error occurs.)
 
result-prefix
 
The mandatory result-prefix attribute is the new namespace (prefix) that will appear in the output. For example, if you are mapping literal result elements into the XSLT namespace, then this value will be: result-prefix="xsl"
 
We use the DevGuru Staff List XML file for our example with the following header:
<?xml-stylesheet type="text/xsl" href="xslt_example_namespacealias.xsl"?>
and we name it: xslt_example_namespacealias.xml
 
This stylesheet generates a very simple stylesheet where the guru prefix is converted to the xsl prefix.
 
Code for xslt_example_namespacealias.xsl:
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:guru="guru.xsl">
<xsl:param name="var">name</xsl:param>
<xsl:param name="blank"></xsl:param>
<xsl:namespace-alias stylesheet-prefix="guru" result-prefix="xsl" />
<xsl:template match="/">
<guru:stylesheet version="1.0">
<guru:variable name="{$var}">
<guru:value-of select="{$blank}" />
</guru:variable>
</guru:stylesheet>
</xsl:template>
</xsl:stylesheet>

 
Output:
 
Click to view output in separate window - requires Internet Explorer Shows the generated XSL file.

 
 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information