Defining Namespace Prefixes for Extension Funtions

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XPath Reference

Defining Namespace Prefixes for Extension Functions

To use the Microsoft XPath Extension functions, you must declare the appropriate namespaces in an XSLT style sheet, as follows:

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

It is important that the namespace URI, urn:schemas-microsoft-com:xslt, must appear exactly as shown above. It is reasonable to choose ms as the namespace prefix, although you can use a name of your choosing for the prefix. For example, the following code snippet is equally valid:

<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     "xmlns:ext="urn:schemas-microsoft-com:xslt"
                          version="1.0">
...
<xsl:template match="*">
   <xsl:value-of select="ext:type-local-name()"/>
</xsl:template>
...
</xsl:template>

The namespace prefix can also be defined within the XSLT element, as follows.

<xsl:for-each select="//[ms:type-local-name()='ID'] xmlns:ms="urn:schemas-microsoft-com:xslt">

When using the DOM, the namespace prefix is declared using the setProperty method of IXMLDOMDocument2.

docObj.setProperty("SelectionNamespaces", "xmlns:ms='urn:schemas-microsoft-com:xslt'")

See Also

setProperty method | Using Namespaces in Documents