home contribute faq download

FunctX XQuery Functions

fn:namespace-uri-for-prefix

The namespace associated with a prefix, in the scope of an element

Google
Webxqueryfunctions.com

Description

The fn:namespace-uri-for-prefix function returns the namespace mapped to $prefix, using the in-scope namespaces of $el e ment. If $prefix is a zero-length string or the empty sequence, the function returns the default namespace, if any.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$prefix xs:string? the prefix to check for
$element element() the element to use as the scope
return value xs:anyURI?

Examples

declare namespace pre = "http://datypic.com/pre";
declare namespace unpre = "http://datypic.com/unpre";
let $in-xml :=
<noNamespace>
     <pre:prefixed xmlns="http://datypic.com/unpre"
              xmlns:pre="http://datypic.com/pre">
       <unprefixed pre:prefAttr="a" noNSAttr="b">123</unprefixed>
     </pre:prefixed>
   </noNamespace>
return
XQuery ExampleResults
namespace-uri-for-prefix(
  '', $in-xml)
()
namespace-uri-for-prefix(
  'pre',$in-xml)
()
namespace-uri-for-prefix(
  'pre',$in-xml//pre:prefixed)
http://datypic.com/pre
namespace-uri-for-prefix(
  '',$in-xml//unpre:unprefixed)
http://datypic.com/unpre
namespace-uri-for-prefix(
  'pre',$in-xml//unpre:unprefixed)
http://datypic.com/pre

See Also

fn:in-scope-prefixesThe prefixes that are in scope for an element
functx:namespaces-in-useA list of namespaces used in element/attribute names in an XML fragment
fn:resolve-QNameResolves a QName based on the in-scope namespaces of an element
fn:namespace-uriThe namespace URI of a node
fn:namespace-uri-from-QNameThe namespace part of a QName

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery