≡ Menu

XQuery Hello World Example: How To Write and Execute XQuery Program on Linux OS

Question: I would like to understand the basics of how to write and execute XQuery program on Linux OS. Can you explain it with a simple example?

Answer: In this article, let us review very quickly how to write a basic Hello World XQuery program and execute XQuery program on Linux or Unix OS.

1. Write a Hello World XQuery Program

Create the helloworld program using a Vim editor as shown below.

$ vim helloworld

(: Hello World with XQuery :)
let $i := "Hello World!"
return $i

A very simple version of hello world

$ vim helloworld-simple
"Hello World!"

Note: Comment in XQuery starts with “(:”, and ends with “:)”.

2. Make sure XQuery Interpreter is installed on your system

Make sure XQuery interpreter xqilla is installed on your system as shown below.

$ which xqilla

Installing XQilla interpreter

If you don’t have XQuery interpreter, install it as shown below.

$ sudo apt-get install xqilla

3. Execute the XQuery Program

You can execute using xqilla helloworld.

$ xqilla helloworld
Hello World!

( or )
$ xqilla helloworld-simple
Hello World!

Note: As XQuery is an interpreted language, you don’t have the compilation step similar to the C program.

4. Additional XQuery Resources

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Movpix April 7, 2011, 12:41 pm

    Thank you for information about xqilla, I’ll try that to learn XQuery script.

  • Ige June 22, 2015, 1:53 pm

    Is it possible to run a bash script from xquery, xquilla?