home contribute faq download

FunctX XQuery Functions

fn:prefix-from-QName

The prefix portion of a QName

Google
Webxqueryfunctions.com

Description

The fn:prefix-from-QName function returns the prefix associated with a particular qualified name. Note that the prefix associated with a qualified name selected from an input document will be the prefix that is used in that input document, not a prefix used in the query.

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

NameType
$arg xs:QName?
return value xs:NCName?

Examples

declare namespace pre2 = "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 ExampleResultsExplanation
prefix-from-QName(
  node-name($in-xml))
()
The prefix pre2 is used rather than pre to demonstrate that when selecting nodes from an instance document, it is the prefix used in the instance document (not the query) that is returned.
prefix-from-QName(
  node-name($in-xml//pre2:prefixed))
pre
prefix-from-QName(
  node-name($in-xml//unpre:unprefixed))
()
prefix-from-QName(
  node-name($in-xml//@pre2:prefAttr))
pre
prefix-from-QName(
  node-name($in-xml//@noNSAttr))
()
prefix-from-QName(
  node-name(<pre2:new>xyz</pre2:new>))
pre2
when constructing a new element, the prefix used in the query itself is the one associated with the name

See Also

fn:local-name-from-QNameThe local part of a QName
fn:namespace-uri-from-QNameThe namespace part of a QName
fn:namespace-uri-for-prefixThe namespace associated with a prefix, in the scope of an element
fn:in-scope-prefixesThe prefixes that are in scope for an element

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