Other Standards

You should be aware of several other standards before building your applications. Again, if you have a need or a problem to solve, someone else or another company probably had the same need as well. Knowing and understanding these standards will accelerate your time to deployment.

In this section we will look at a few standardization efforts. Specifically, we are going to look at one effort that attempts to define a method for including pieces of XML documents within other documents, and a second effort that defines a means with which to query XML documents for information.

XML Inclusions

XML Inclusions (XInclude) defines a method by which XML documents can be, at processing time, included in other documents. In much the same manner that Server Side Includes (SSI) work, XInclude syntax defines the grammar of how to reference other documents within a parent document.

For example, XMLInclude could be used if you wanted to include today's news on a page within your site, but the news was contained in a separate document. Historically you would've accomplished this with server-side processing an <iframe> element, but this approach does not really make the data "part" of the parent document. Using XInclude, however, you can reference your news document within the body of the document in which you want to include this information, and when processed, a single document will result.

To help you better understand this, we've built xinclude.xml (Listing A-12), a simple XHTML document, that contains a reference to a second document for inclusion.

Listing A-12 xinclude.xml: An XHTML document that contains a separate XIncluded document.

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=/1999/xhtml" 
      xmlns:xinclude=/1999/XML/xinclude"
      lang="en" xml:lang="en">
<head>
  <title>XInclude</title> 
</head>
<body>
  <h1>Today's News</h1>
  <xinclude:include href="news.xml" />
</body>
</html>

As you can see, the syntax for this inclusion is simple. Using the XInclude namespace, we use the <include> element to specify the news.xml document for inclusion. Listing A-13, the news.xml document, only contains some basic information for our news stories.

Listing A-13 news.xml: A sample news document we will use for inclusion.

<h2>Sports</h2>
<p>
  The NHL is nearing the end of their season, and the race 
  for the cup is in full swing. <a href="nhl.xml">Read
  more...</a>
</p>
<h2>Travel</h2>
<p>
  Airfares continue to go down as the economy slows. 
  <a href="nhl.xml">Read more...</a>
</p>

When processed, the resulting document (xinclude-result.xml), after inclusion, will look like the following:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=/1999/xhtml" 
      xmlns:xinclude=/1999/XML/xinclude"
      lang="en" xml:lang="en">
<head>
  <title>XInclude</title> 
</head>
<body>
  <h1>Today's News</h1>
  <h2>Sports</h2>
  <p>
    The NHL is nearing the end of their season, and the race 
    for the cup is in full swing. <a href="nhl.xml">Read
    more...</a>
  </p>
  <h2>Travel</h2>
  <p>
    Airfares continue to go down as the economy slows. 
    <a href="nhl.xml">Read more...</a>
  </p>
</body>
</html>

XInclude might look like a relatively simple standard, but if you think of the overall picture of creating a semantic Web where content is not replicated, but referenced and included, it presents a compelling message for managing your content.

XInclude is currently a Working Draft at the W3C, so there could be substantial changes in the specification before it become a complete Recommendation. For this reason, we limit our coverage here to the basics.

XML Query

One of the most powerful aspects of databases is the ability to query them for information—not only bulk information, but also for information that only fits specific criteria. The efforts of the XML Query Working Group at the W3C revolve around an attempt to create a standardized method to query XML documents. The desired result was a method to access information from real and virtual (remember XInclude) XML documents like you would a database.

The XML Query work revolves around three core items. First is the XQuery 1.0 and XPath 2.0 Data Model, which is a node-labeled, tree-constructor representation of an XML document that also includes the concept of node identity. Second is XQuery 1.0 Formal Semantics, which defines the operators and grammar for querying XML documents. Finally, the group created XQuery, which is a query language built on XQuery 1.0 Formal Semantics, for querying XML documents.

The works of the XML Query Working Group are currently at a Working Draft state, and therefore unstable at this point. While we recommended you read and familiarize yourself with the standard, we do not advise you to begin building applications using the guidelines it defines. However, Microsoft has created a prototype application using a version of XML Query that you can experiment with at . If you need to build applications soon, we recommend you contact the working group at and ask to be involved. Otherwise, wait until the Proposed Recommendation is published.