<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.resolveQName.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.resolveQName</api:function-name><api:suggest>fn.resolveqname</api:suggest><api:suggest>fn</api:suggest><api:suggest>resolveqname</api:suggest><api:function-link mode="xquery" fullname="fn:resolve-QName">/apidoc/8.0/fn:resolve-QName.xml</api:function-link><api:function mode="javascript" name="resolveQName" type="builtin" lib="fn" category="QNameBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.resolveQName"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
  Returns an <code>xs:QName</code> value (that is, an expanded QName)
  by taking an <code>xs:string</code> that has the lexical form of an
  <code>xs:QName</code> (a string in the form "prefix:local-name" or
  "local-name") and resolving it using the in-scope namespaces for a
  given element.
</p>
</api:summary><api:params><api:param name="qname" type="xs:string?"><api:param-description>
  A string of the form "prefix:local-name".
  </api:param-description><api:param-name>qname</api:param-name><api:param-type>String?</api:param-type></api:param><api:param name="element" type="element()"><api:param-description>
  An element providing the in-scope namespaces to use to resolve the
  qualified name.
  </api:param-description><api:param-name>element</api:param-name><api:param-type>Node</api:param-type></api:param></api:params><api:return>xs.QName?</api:return><api:usage>
<p xmlns="http://www.w3.org/1999/xhtml">Sometimes the requirement is to construct an <code>xs:QName</code>
without using the default namespace. This can be achieved by writing:
</p>
<pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
     if ( fn:contains($qname, ":") )
     then ( fn:resolve-QName($qname, $element) )
     else ( fn:QName("", $qname) )
</pre>
<p xmlns="http://www.w3.org/1999/xhtml">If the requirement is to construct an <code>xs:QName</code> using the
namespaces in the static context, then the <code>xs:QName</code>
constructor should be used.
</p>
<p xmlns="http://www.w3.org/1999/xhtml">
If $qname does not have the correct lexical form for <code>xs:QName</code>
an error is raised [err:FOCA0002].
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $qname is the empty sequence, returns the empty sequence.
</p><p xmlns="http://www.w3.org/1999/xhtml">
More specifically, the function searches the namespace bindings of $element for
a binding whose name matches the prefix of $qname, or the zero-length string
if it has no prefix, and constructs an expanded QName whose local name is
taken from the supplied $qname, and whose namespace URI is taken from the
string value of the namespace binding.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If the $qname has a prefix and if there is no namespace binding for $element
that matches this prefix, then an error is raised [err:FONS0004].
</p><p xmlns="http://www.w3.org/1999/xhtml">
If the $qname has no prefix, and there is no namespace binding for $element
corresponding to the default (unnamed) namespace, then the resulting
expanded QName has no namespace part.
</p><p xmlns="http://www.w3.org/1999/xhtml">
The prefix (or absence of a prefix) in the supplied $qname argument is retained
in the returned expanded QName, as discussed in Section 2.1 Terminology[DM].
</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var foo = xdmp.unquote('&lt;foo xmlns:eg="eg"/&gt;');
var el = foo.toArray()[0].xpath("/element()");
fn.resolveQName("hello", el);

=&gt; a QName with local name "hello"
   that is in no namespace.

var foo = xdmp.unquote('&lt;foo xmlns:eg="eg"/&gt;');
var el = foo.toArray()[0].xpath("/element()");
fn.resolveQName("eg:myFunc", el);

=&gt; an xs:QName whose namespace URI is specified
   by the namespace binding corresponding to the
   prefix "eg" and whose local name is "myFunc".
</pre>
</api:example></api:function></api:function-page>