Home » XQuery String Lngth() Function

XQuery String Lngth() Function

by Online Tutorials Library

XQuery string-length() Function

The XQuery string-length function is used to get the length of a string.

Parameter explanation:

$string: It specifies the provided string.


XQuery string-length Example

Let’s take an example to demonstrate the usage of XQuery string-length function. Take an XQuery expression named “books.xqy”, having the following code.

XQuery Expression:

books.xqy:

Create a Java based XQuery executor program to read the books.xqy, passes it to the XQuery expression processor, and executes the expression. After that the result will be displayed.

XQueryTester.java


Execute XQuery against XML

Put the above both files to a same location. We put them on desktop in a folder name XQuery13. Compile XQueryTester.java using console. You must have JDK 1.5 or later installed on your computer and classpaths are configured.

Compile:

javac XQueryTester.java

Execute:

java XQueryTester

Output:

XQUERY String length function 1

The above example specifies that the given string-length is 16. Space is treated as length character.

You may also like