Accessing Databases with XQuery

At the start of this section, we stated that the main purpose of XQuery is to extract data from XML databases, but all our examples have used a single XML document as input.

People sometimes squeeze a large data set (for example, a corporate phone directory) into a single XML document, and process it as a file without the benefit of any database system. While there are preferable alternatives, if the data volumes do not go above a few megabytes and the transaction rate is modest, then XML-document-as-database is a perfectly feasible storage mechanism. In other words, the examples in this section are not totally unrealistic.

If you have got a real database, however, the form of the queries used in this section will not need to change all that much from these examples. Instead of using the doc() function (or simply " .") to select a document, you are likely to call the collection() function to open a database, or a specific collection of documents within a database. The actual way collections are named is likely to vary from one database system to another. The result of the XQuery collection() function is a set of documents (more strictly, a sequence of documents, but the order is unlikely to matter), and you can process this using XPath expressions or FLWOR expressions in just the same way as you address a single document.

There is a lot more to databases than doing queries, of course. Each product has its own ways of setting up the database, defining schemas, loading documents, and performing maintenance operations such as backup and recovery. XQuery currently handles only one small part of the job. In the future it is also likely to have an update capability, but in the meantime each vendor is defining his own.

One particularly nice feature of XQuery is that it has the potential to combine data from multiple databases (and freestanding XML documents). DataDirect XQuery, which supports access to Oracle, DB2, SQL Server, and Sybase is one product that addresses this need.

Simple API for XML (SAX)

SAX stands for Simple API for XML - SAX is an XML standard used everywhere in Stylus Studio, for parsing and building representations of XML documents.

XSLT Profiler

Stylus Studio's XSL and XSLT profiler allows you to create detailed XSLT performance metrics profiles of any stylesheet in a processor-independent way.

Biotechnology & Pharmaceuticals

Leading biotechnology & pharmaceuticals companies take Stylus Studio when they are feeling under the weather. Come see for yourself how Stylus Studio can be a pick me up for your biotechnology or pharmaceutical company.

WYSIWYG XSLT Designer

Stylus Studio's powerful and easy-to-use WYSIWYG ("What you see is what you get") XSLT Designer lets you create XSLT stylesheets without writing any code! Go from a blank slate to solid, robust XSLT in minutes, using simple drag-and-drop operations.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member