The namespace-uri() function

Smartsite 7.4 - ...

The namespace-uri() XPath 2.0 function returns the namespace URI part of the name of the specified node.

XML CopyCode image Copy Code
string fn:namespace-uri(arg1)

Parameters:

  • arg1: a node reference. 

Example

XML CopyCode image Copy Code
<html xmlns="http://www.w3.org/1999/xhtml" 
  xmlns:xf="http://www.w3.org/2002/xforms" 
  xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0" 
  xmlns:meta="http://smartsite.nl/namespaces/metadocument/2.0" 
  xmlns:fn="http://www.w3.org/2005/xpath-functions" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:cust="http://example.org">
    <head>
      <title>XForms Document</title>
      <xf:model>
        <xf:instance>
          <data xmlns="http://smartsite.nl/namespaces/metadocument/2.0">
            <entry xmlns:cust="http://example.org">
              <code>abc</code>
              <cust:strings>
                <cust:string index="1">a</cust:string>
                <cust:string index="2" cust:prefattr="prefixed attribute">c</cust:string>
              </cust:strings>
            </entry>
          </data>
        </xf:instance>
      </xf:model>
    </head>
    <body>
      <xf:group ref="meta:entry">
        <xf:label />
        <xf:output value="fn:namespace-uri(meta:code)" />
        <xf:output value="fn:namespace-uri(//cust:strings)" />
        <xf:output value="fn:namespace-uri(//cust:string[1]/@index)" />
        <xf:output value="fn:namespace-uri(//cust:string[2]/@cust:prefattr)" />
      </xf:group>
    </body>
</html>

The result will be:

http://smartsite.nl/namespaces/metadocument/2.0
http://example.org
http://example.org
 
Namespace

This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).