home contribute faq download

FunctX XSLT Functions

fn:data

The atomic value of a node

Google
Webxsltfunctions.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

<xsl:variable name="cat" select="doc('http://www.functx.com/input/catalog.xml')"/>
XSLT ExampleResults
<data($cat>ata($cat//product[1]/number)
<557>57
<data($cat>ata($cat//number)
<(557,>557, 563, 443, 784)
<data($cat>ata($cat//product[1]/@dept)
<WMN>MN
<data($cat>ata($cat//product[1]/colorChoices)
<navy>avy black
<data($cat>ata($cat//product[1])
<557>57 Fleece Pullover navy black
<data($cat>ata($cat//product[4]/desc)
<Our>ur favorite shirt!
The additional examples below yield different results if the input document was validated with the schema shown here.
<data($cat>ata($cat//product[1]/colorChoices)
<('navy', 'black'>
<data($cat>ata($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 XSLT Services

Recommended Reading:

XQuery