XQuery Built-in Functions

XQuery has a large library of built-in functions, which are all supported by DataDirect XQuery®. The vast majority of these are translated into SQL. For some of these functions, the translation is straightforward; for others, the translation requires more thought. We do not know of another XQuery implementation in which such a high proportion of XQuery functions are executed directly in the database.

Example 13. A Straightforward Built-in Function

XQuery

for $u in collection('USERS')/USERS
return concat($u/FIRSTNAME,$u/LASTNAME)

Generated SQL

SELECT ALL
{fn CONCAT(nrm5."FIRSTNAME",nrm5."LASTNAME")} AS RACOL1
FROM
"PEPPINO"."USERS" nrm5

For most of the functions in the XQuery built-in library, though, translating to efficient SQL is non-trivial. DataDirect XQuery® does this without changing the semantics of the XQuery function.

Example 14. A More Complex XQuery Built-in Function

XQuery

for $u in collection('USERS')/USERS
return substring-before($u/FIRSTNAME, 'lo')

Generated SQL

SELECT ALL
(CASE WHEN
{fn LOCATE('lo',nrm5."FIRSTNAME")} > 0
THEN
{fn LEFT( nrm5."FIRSTNAME", {fn LOCATE('lo',nrm5."FIRSTNAME")} -1)}
ELSE
'' END) AS RACOL1
FROM
"PEPPINO"."USERS" nrm5

This translation uses features found only in Oracle databases along with JDBC escapes that are standard, but not supported by all drivers - and these features are needed to implement substring-before() efficiently. Different features are used on other databases to achieve an efficient and conformant implementation.

Try DataDirect XQuery® Free!

Put the power, scalability, and performance of DataDirect XQuery® to work for you today! Our free trial lets you see for yourself how easy it is to build data integration applications that access relational, EDI, and other file formats as XML!

Download DataDirect XQuery® today!

Online Video Tutorials!

Our easy-to-follow online video tutorials are a great way to get acquainted with the many features of DataDirect XQuery®.

And if you like what you see, download a free copy today and try DataDirect XQuery® for yourself!

Back to School with DataDirect XQuery®

Getting your mind around the possibilities of a data integration technology as promising as XQuery can be difficult, but our XML developers Webinars will help you understand the power and versatility of XQuery, and our favorite XQuery processor, DataDirect XQuery®.

New Features in DataDirect XQuery®

DataDirect XQuery® is now released!

DataDirect XQuery® provides full update support for relational data, easy integration for Web Services, additional enhancements for performance and scalability and more!

Download now!