Extracts the namespace URI from $QName-var.
A QName (qualified name) is made up of a namespace name and a local part. The namespace name is the URI associated with the prefix of a namespace declaration.
If the value of $QName-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
If a QName is not passed into $QName-var, the following error is displayed in the mapper:
Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: Type error in function get-namespace-from-QName invocation: expected type [QName@http://www.w3.org/2001/XMLSchema]?, given type [string@http://www.w3.org/2001/XMLSchema]
xf:get-namespace-from-QName(xs:QName? $QName-var) —> xs:anyURI?
Represents the QName to extract from. |
Returns the URI (of data type anyURI) of the namespace in $QName-var.
The following XML document defines the namespace called xacme:
<?xml version='1.0'?> <mydoc xmlns:xacme="http://www.acme.com/foo"> <xacme:n/> </mydoc>
The preceding XML Document associates the namespace prefix xacme to the URI: http://www.acme.com/foo. The string xacme:n is qualified name for the URI/local name pair: ("http://www.acme.com/foo", "n").
The following example query calls the get-namespace-from-QName function:
let $a := <mydoc xmlns:xacme="http://www.acme.com/foo"> <xacme:n/> </mydoc> return <name>{ xf:get-namespace-from-QName(xf:node-name($a/*[1])) }</name>
The preceding query generates the following result:
<name>http://www.acme.com/foo</name>
W3C get-namespace-from-QName function description.