Skip to main content

skip to main content

developerWorks  >  Web development  >

AjaXQuery

Using Ajax with XQuery In Web applications

developerWorks
Go to the previous pagePage 2 of 10 Go to the next page

Document options
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
365 KB (26 pages)

Get Adobe® Reader®

Sample code


My developerWorks needs you!

Connect to your technical community


Rate this tutorial

Help us improve this content


The introductions

These brief introductions to XQuery and Ajax fill you in on what you need to know to get started.

A brief introduction to XQuery

It's this simple: XQuery is to an XML document what Structured Query Language (SQL) is to a relational database. XQuery enables you to use expressions to extract data from an XML document. That data can include one simple value or an entire subtree of the document, such as an element and all of its children.

To accomplish this, XQuery uses XPath expressions, which involve the famous "FLWOR" expressions. These expressions provide a powerful means of extracting and returning data from XML documents in almost any fashion imaginable.

The syntax of the language is based on the tree-like nature of the XML document itself. XQuery is aware of processing instructions and attributes as well as elements.

Please note that for XQuery to function properly, the XML document being queried must be well formed, but not necessarily valid. Recall that a well-formed XML document means that it conforms to the World Wide Web Consortium's (W3C's) XML standard. (See Resources for more information.) An XML document is valid when it conforms to its own Document Type Definition (DTD) or schema.



Back to top


A brief introduction to Ajax

Ajax is one of the latest bleeding-edge technologies Web developers use to enable rich client presentation. It accomplishes this by invoking a new request without disrupting the current view. An XML document is returned that is then displayed to the user, frequently as a sub-page within the current presentation. In short, Ajax gives you the benefit of server-side dynamic content while still looking like client-side dynamic content.

Ajax generally fulfills its billing through the use of the XMLHttpRequest Document Object Model (DOM) API, which—until the advent of Ajax—Web developers rarely used. The request itself can be either one of the GET or POST varieties. As with any other request, a response is returned, which can be an error. If the response is not erroneous, the actual text of the response is used to update the current view.

Remembering a famous statement by Voltaire (namely, "The Holy Roman Empire was neither holy, nor Roman, nor an empire"), thorough research into various Ajax implementations leads one to realize that Ajax does not require JavaScript code, does not require XML, and does not need to be asynchronous. After stripping all of that out, the only part left in the acronym is the conjunction and. But the acronym sounds cool, so the industry has decided to keep it.



Back to top



Go to the previous pagePage 2 of 10 Go to the next page