ms:namespace-uri Function

Resolves the prefix part of a qualified name into a namespace URI.

string ms:namespace-uri(string)


The ms:namespace-uri() function assumes that the parameter is a qualified name (for example, q:mine or coffee:beans) and attempts to resolve its prefix in the context of the current node. If the argument is not a qualified name or a noncolon name, this function returns an empty string. For nonstring arguments, this function behaves as if a string() function were applied.


The following example uses an XSLT template rule to select all the elements in books.xml, and to output the elements' data types and the namesapce URI as defined in books.xsd.

XML File (books.xml)

Use the XML file in Using XPath Extension Functions for XSD Support.

XSD File (books.xsd)

Use the XSD file in Using XPath Extension Functions for XSD Support.

HTML File (books.html)

The HTML file is the same as that listed in the ms:type-namespace-uri([node-set]) Function topic.

XSLT File (books.xsl)

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" 
  <xsl:template match="text()"/>
  <xsl:output method="html"   

  <xsl:template match="/">

  <xsl:template match="*">
    <xsl:if test="ms:type-namespace-uri() != ''">
          <xsl:value-of select="ms:namespace-uri(name())"/>:
          <xsl:value-of select="ms:local-name(name())"/>
          <xsl:value-of select="namespace-uri()"/>:
          <xsl:value-of select="local-name()"/>
          <xsl:value-of select="name()"/> 



(ms:) urn:books:catalog

(std:) urn:books:catalog

(name():) x:catalog

The first line of the output is the result returned by the ms:namespace-uri(string) plusms:local-name(string). The second line is the results from the standard XPath function, namespace-uri(nodeset), local-name(nodeset). The third line is the result from the standard XPath function,name(nodeset).

See Also


XML Schemas (XSD) Reference
XML Data Types Reference