Declaring the msxsl: Namespace Prefix

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XSLT Developer's Guide

Declaring the msxsl: Namespace Prefix

Before using the msxsl:node-set() function in an XSLT style sheet, you must declare the msxml: namespace prefix. Most often this is done in the root <xml:stylesheet> element of the style sheet, as shown below:

XSLT File (msxsldecl.xsl)

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:template match="text()"/>

</xsl:stylesheet>

As with other namespace declarations, the prefix (such as msxsl:) is not important. Only the namespace URI (that is, the value of the xmlns attribute) is important. To use the Microsoft implementation of the node-set() extension function, that value must be "urn:schemas-microsoft-com:xslt". For example, you could use either of the following two namespace declarations, as long as all references to the node-set() function appear as ms:node-set() or xyz:node-set(), respectively.

  • xmlns:ms="urn:schemas-microsoft-com:xslt"
  • xmlns:xyz="urn:schemas-microsoft-com:xslt"

Throughout this topic, we have used the msxsl: prefix.

Note   The Uniform Resource Identifier (URI) for using Microsoft extensions to core W3C technologies takes the form of a Uniform Resource Name (URN), such as urn:schemas-microsoft-com:xslt. This is an accepted alternative to a Uniform Resource Locator (URL), such as http://www.w3.org/1999/XSL/Transform.
Also note that declaring the msxsl: namespace gives your style sheet access not only to the msxsl:node-set() function, but also to other Microsoft extensions, such as the <msxsl:script> element.