Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XQuery data and text() function

Tags:

text

xquery

Sorry even trying to watch tutorials I am just trying to understand the difference between the data() and the text() functions in XQuery.

Any clarification is appreciated.

like image 326
TheWommies Avatar asked Oct 11 '13 07:10

TheWommies


1 Answers

text() is used to match something. For example if we have this structure:

<a>
  <b>hello <c>world</c></b>
</a>

Doing //b/text() will return the text node 'hello ' just like //b/element() will return the element c.

data($arg) is a function that returns the atomic value of a node, for example data(//b) will return 'hello world'. If you use the data($arg) function on a document with a schema then the type will be kept intact.

like image 117
Ewout Graswinckel Avatar answered Sep 18 '22 14:09

Ewout Graswinckel