Altova is providing its AltovaXMLTM engine as a free download (and it is royalty-free). You download the engine and learn more about it here. I will discuss using this engine with .NET to process XQuery statements.
AltovaXMLTM is an XML standards processor (see the World Wide Web Consortium at www.w3c.org for more) that includes engines that drive Altova’s products, like their XMLSpyTM product. XMLSpy is the industry standard for working with XML. While the price of the product has grown with each new release, so has the capability of the product and the feature set is quite rich.
That having been said, the documentation is somewhat sparse. However, yours truly has spent a little time with this free product in an attempt to make use of the XQuery portion of the processor. With a little bit of trial-and-error, you can develop a very nice XQuery processor application with Visual Studio .NET. This example uses .NET Framework 1.1, but I recently demonstrated a version of this same application that runs quite well with Visual Studio 2005 Beta 2 (.NET Framework 2.0).
The AltovaXML engine comes with interfaces for COM, Java, and .NET. Adding the engine to your project via the “References” is described quite well in the help files that come with the engine, so they will not be discussed here.
Here is the object browser view of the XQuery class. Note that there are a handful of methods for declaring input, ouptut, and error attributes.

In the code line below, note that an AltovaXMLLib Application is instantiated. From this object we will reference and begin to work with the XQuery engine.
[Note: For some reason some of the XQuery calls that involve references to an external XML file do not work if you use the AltovaXMLLib.Application.XQuery object directly. Creating an XQuery variable and setting it to the AltovaXMLLib.Application.XQuery works as expected.]

In the first few lines, we declare if there is an external source for the XML input file by providing the URL to the file. This can be either a local file path or a URL to an external XML document (like an RSS feed).
Note that the code specifies receiving the XQuery text from a textbox control on the user interface. It is also possible to receive the XQuery from an external file.
The output result is specified as either XML or Text depending upon our choice.
Here is the program running with a resultant output.

In the VS2005 version that I demonstrated at the CAPAREA user group presentation, I added an additional form that contained a web-browser control for displaying XML data.
When you run the application, you get this command window that pops up that contains a reference to Altova’s copyright. As long as you continue to use the same AltovaXMLLib Application object, you will only have one of these windows open. So, in other words, everytime you instantiate an AltovaXMLLib Application object, you get this command window that pops up.

Running XQuery Statements
Setting the input file to an RSS feed, you can generate some results that demonstrate the power of XQuery over XML data. I used the Microsoft MSDN feed for my input file (http://msdn.microsoft.com/rss.xml). Note that this feed formats the data using XSL when you open it in your browser - to see the raw feed select Source under the View menu in IE.
Use this XQuery statement to return the entire XML tree from the document root:
|
for $rss in /rss
return $rss |
Notice “/rss” is an XPath statement to the document element in an RSS feed. This is assigned to the “$rss” variable, which is returned as output.
Use this XQuery statement to return a text output containing just the titles of all the RSS items:
|
for $rss in //item
let $carriageReturn := " "
return
concat($rss/title, $carriageReturn ) |
In this statement, we assign the line-feed/carriage return ASCII values (" ") to the variable $carriageReturn. This is concatenated onto each title string that is returned.
Use this XQuery statement to return a text output containing title and date for each item in the RSS feed:
|
for $rss in //item
let $carriageReturn := " "
let $div := "//"
return
concat($rss/title,
concat($div,
concat($rss/pubDate, $carriageReturn)
)
) |
Notice the nested concatenation and multiple let assignments.
The resulting output looks like this:
A New Alliance—Palm and Windows Mobile 5.0!//Sat, 01 Oct 2005 00:08:04 GMT
Persisting Ink on the Web//Fri, 30 Sep 2005 22:51:34 GMT
In conclusion, the Altova XML engine is a very good starting point for developers that want to try their hand at XQuery, and the engine can be integrated directly into your .NET applications.