Loading TOC...

MarkLogic 12 EA 1 Product Documentation
fn:namespace-uri-for-prefix

fn:namespace-uri-for-prefix(
   $prefix as xs:string?,
   $element as element()
) as xs:anyURI?

Summary

Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix.

If $element has an in-scope namespace whose namespace prefix is equal to $prefix, it returns the namespace URI of that namespace. If $prefix is the zero-length string or the empty sequence, it returns the namespace URI of the default (unnamed) namespace. Otherwise, it returns the empty sequence.

Prefixes are equal only if their Unicode code points match exactly.

Parameters
prefix A namespace prefix to look up.
element An element node providing namespace context.

Example

xquery version "1.0-ml";
declare namespace ex = "http://www.example.com/example";

let $x := <ex:hello>1</ex:hello>
return
fn:namespace-uri-for-prefix("ex", $x)

=> the namespace URI corresponding to
   "http://www.example.com/example".  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.