Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

XQuery, the Query Language of the Future : Page 3

XQuery 1.0 still has to reach W3C Recommendation status, but the available implementations and technology previews show that it is a very potent query language.


advertisement

XQuery in .NET
Microsoft offers XQuery demo classes for the .NET Framework through http://xqueryservices.com. You can either use the online demo with several of the XQuery User Cases (see sidebar), or download the classes and experiment with them yourself. Note that this is just a demo implementation. The namespace and the classes are likely to change for the actual implementation. The overall structure and approach, however, will probably stay the same.

Most W3C standards that deal with XML are usually specified in XML format (XSLT, for example). XQuery represents a departure from this standard.
Executing a query consists of two steps: loading the document(s), and executing the query over the loaded documents, as shown in Figure 1. The documents you load are stored in an XQueryNavigatorCollection object. You can either load a file directly into the collection, or load an XQueryDocument using an XmlReader object, and from there use the CreateNavigator() method to create an XQueryNavigator object that you store in the collection. The result is a collection of documents optimized for XQuery. When you execute a query, you feed the collection to the XQueryExpression object executing the query. An advantage of this approach is the ability to work with both physical and virtual documents because the documents are loaded into the collection using an alias. To refer to a document in the query, you refer to the alias. If this wasn't possible, you could only work on physical documents, because, for instance, there is no way to address data in a database.



Michiel van Otegem is the co-founder and president of ASPNL.com, a consulting and training firm based in Amsterdam, the Netherlands. He teaches advanced ASP.NET and XML classes, and is a frequent seminar speaker. He is also the author of Sams Teach Yourself XSLT in 21 Days. Michiel is a respected member in the international ASP/ASP.NET community, helping on forums and mailing lists. In his spare time he is also the president of the Dutch .NET user group, Stichting dotNED.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.