So here it is:
If you just add the above line to a text file, usually with the *.xqy, *.xq or *.xquery extension, then initiate a transformation using your favorite XQuery processor, you should see the string "hello world" in the output.
What processor to use
well I would go for something like Saxon, if you're just querying static XML files on your file system, or passing a standalone XML file to the processor at run time.
If you really want to see XQuery at it's best I'd recommend using an XML database as the repository for your XML content. or that you can try MarkLogic or eXist amongst others.
Most of the examples you'll see in future blogs are based on MarkLogic, as it is the processor I have the most experience with, but given the fact that ML has just gone closer to full compliance with W3C 1.0 XQuery standards, chances are that the examples you'll come across are as applicable in any other XQuery processor.
Now back to our code . . . What does "hello world" really mean?
Well the value between the quotes represents a item() of type xs:string. XQuery uses the same Data model as XPath 2.0, so if you're familiar with XSLT and XPath 1.0, then you'll find it really easy to understand the concepts of XQuery.
For a better understanding of data types in XQuery have a look at the XQuery 1.0 and XPath 2.0 Data Model.
Just to keep it simple I'll give you an example of a query, that interrogates an XML file, passed as the input xml to saxon.
The input xml:
<groups><group id="1"/><group id="2"/></groups>
the xquery file : my-lovely-query.xqy
This query returns:
The above represents a sequence of items of type element(group). This means the XPath expression "/groups/group" returned all "group" child element nodes of the root element "groups".
I think this illustrates nicely the very basics of XQuery. I'll get into more detail as new blogs are added.