home contribute faq download

FunctX XQuery Functions

fn:data

The atomic value of a node

Google
Webxqueryfunctions.com

Description

The fn:data function accepts a sequence of items and returns their typed values. For atomic values, this simply means returning the value itself, unchanged. For nodes, this means extracting the typed value of the node.

Calling this function is often unnecessary because the typed value of a node is extracted automatically (in a process known as atomization) for many XQueryXPath 2.0 expressions, including comparisons, arithmetic operations and function calls. The most common use case for the fn:data function is in XQuery element constructors.

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
$arg item()* the item to get the value of
return value xs:anyAtomicType*

Examples

let $cat :=
doc('http://www.functx.com/input/catalog.xml')
return
XQuery ExampleResults
data($cat//product[1]/number)
557
data($cat//number)
(557, 563, 443, 784)
data($cat//product[1]/@dept)
WMN
data($cat//product[1]/colorChoices)
navy black
data($cat//product[1])
557 Fleece Pullover navy black
data($cat//product[4]/desc)
Our favorite shirt!
The additional examples below yield different results if the input document was validated with the schema shown here.
data($cat//product[1]/colorChoices)
('navy', 'black')
data($cat//product[1])
Error FOTY0012

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