<msxsl:using> Element 

Declares additional namespaces for use in script blocks. This element is a child of the <msxsl:script> element.

  namespace = "namespace-name"


Required. References a namespace for use within the script block.

Number of occurrences


Parent elements

<msxsl:script> Element


This element is supported only in the .NET Framework.

The namespace declaration allows you to use the types in a namespace without having to specify the namespace.

The namespaces may be user-defined or system-defined.

The following namespaces are in scope by default:

  • System

  • System.Collection

  • System.Text

  • System.Text.RegularExpressions

  • System.Xml

  • System.Xml.Xslt

  • System.Xml.XPath

  • Microsoft.VisualBasic (if Visual Basic is used)

The following example demonstrates accessing a class in a user-defined assembly named MyCompany.HelperAssembly.

This is the C# code contained in the MyCompany.HelperAssembly assembly.

class MyCompany.XmlHelper.NodeContents
   XPathNavigator _nav;

   public NodeContents(XPathNavigator nav)
      _nav = nav;

   public string GetNodeContents()
      return _nav.InnerXml;

The following stylesheet adds a reference to the assembly and imports the appropriate namespace. The classes in the assembly namespace are referenced in the script block.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  <msxsl:script language="C#" implements-prefix="user">
    <msxsl:assembly name="MyCompany.HelperAssembly" />
    <msxsl:using namespace="MyCompany.XmlHelper" />
    function string FragmentValue(XPathNavigator nav)
       NodeContents myContents = new NodeContents(nav);
       return myContents.GetNodeContents();

    <xsl:template match="/">
            <xsl:value-of select="user:FragmentValue(customer[1])"/>