Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development

  • Print
  • + Share This

XML Applications

We've seen a lot of theory in this chapter, so I'm going to spend the rest of this chapter taking a look at how XML is used today in the real world. The world of XML is huge these days; in fact, XML is now used internally even in Netscape and Microsoft products, as well as installations of programming languages such as Perl. You can find a good list of organizations that produce their own XML-based languages at

It's useful and encouraging to see how XML is being used today in these XML-based languages. Here's a new piece of terminology: As you know, XML is a metamarkup language, so it's actually used to create languages. The languages so created are applications of XML; as a result, they're called XML applications.

Note that the term XML application means an application of XML to a specific domain, such as MathML, the mathematics markup language; it does not refer to a program that uses XML (a fact that causes a lot of confusion among people who know nothing about XML).

Thousands of XML applications are around today, and we'll see some of them here. You can see the advantage to various groups when defining their own markup languages. For example, physicists or chemists can use the symbols and graphics of their discipline in customized browsers. In fact, I'll start with Chemical Markup Language (CML) now.

XML at Work: Chemical Markup Language

Peter Murray-Rust developed CML as a very early XML application, so it has been around quite a while. Many people think of CML as a sort of HTML+Molecules, and that's not a bad characterization. Using CML, you can display the structure of complex molecules.

With CML, chemists can create and publish molecule specifications for easy interchange. Note that the real value of this is not so much in looking at individual chemicals as it is in being able to search CML repositories for molecules matching specific characteristics.

I've already mentioned a famous CML browser available: Jumbo, which you can download for free from Jumbo is not only for handling CML; you can also use it to display the structure of an XML document in general. However, there's no question that the novelty of Jumbo is that it can use CML to create graphical representations of molecules.

We've already seen an example in Jumbo in Figure 1-10, where Jumbo is displaying the molecule thiophenol. Here is the file thiophenol.xml that it's reading to display that molecule:

<?jumbo:namespace ns="" prefix="C" 
  java="jumbo.cmlxml.*Node" ?>
<C:molecule id="thiophenol">
  <C:atomArray builtin="elsym">     
    C C C C C C C S C C O O
  <C:atomArray builtin="x2" type="float">
    0 0.866 0.866 0 -0.866 -0.866 
    0.0 0.0 1.732 -1.732 1.732 -1.732
  <C:atomArray builtin="y2" type="float">
    1 0.5  -0.5 -1.0 -0.5  0.5  
    -2.0 2.0 1.0  1.0  2.0  2.0
  <C:bondArray builtin="atid1">
    1 2 3 4 5 6 1 4 2 9 6 10
  <C:bondArray builtin="atid2">        
    2 3 4 5 6 1 8 7 9 11 10 12
  <C:bondArray builtin="order" type="integer">
    4 4 4 4 4 4 1 1 1 2 1 2 

XML at Work: Mathematical Markup Language

Mathematical Markup Language was designed to fill a significant gap in Web documents: equations. In fact, Tim Berners-Lee first developed the World Wide Web at CERN so that high-energy physicists could exchange papers and documents. However, there has been no way to display true equations in Web browsers for nearly a decade.

Mathematical Markup Language (MathML) fixes that. MathML is itself a W3C specification, and you can find it at Using MathML, you can display equations and all kinds of mathematical terms. (It's not powerful enough for many specialized areas of the sciences or mathematics yet, but it's growing all the time.)

Because of the limited audience for this kind of presentation, no major browser yet supports MathML. However, the Amaya browser, which is W3C's own testbed browser for testing new HTML and XHTML elements (but it's not, unfortunately, an XML browser) has some limited support. You can download Amaya for free from

Here's a MathML document that displays the equation 3Z2 – 6Z + 12 = 0 (this document uses an XML namespace, which we'll see more about in the next chapter):

<?xml version="1.0"?>
<html xmlns:m="">

You can see the results of this document in the Amaya browser in Figure 1-13.

Figure 1-13Figure 1-13 Displaying MathML in the Amaya browser.

XML at Work: Synchronized Multimedia Integration Language

Synchronized Multimedia Integration Language (SMIL, pronounced "smile") has been around for quite some time. It's a W3C standard that you can find more about at

SMIL attempts to fix a problem with modern "multimedia" browsers. Usually, such browsers can handle only one aspect of multimedia at a time—video, audio, or images—and never more than that. SMIL lets you create television-like fast cuts and true multimedia presentations by letting you specify when various multimedia files are played.

The idea is that SMIL lets you specify what multimedia files are played when; SMIL itself does not describe or encapsulate any multimedia itself.

Microsoft, Macromedia, and Compaq have a semicompeting specification, HTML+TIME, which I'll take a look at next. Microsoft hasn't implemented much SMIL in Internet Explorer yet because of this reason. You can find a SMIL applet written in Java at, as well as some stunning examples of symphonies coordinated with images.

Here's an example SMIL document that creates a multimedia sequence playing mozart1.wav and, displaying mozart1.htm, then playing mozart2.wav and, and displaying mozart2.htm:

<?xml version="1.0"?>
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 1.0//EN" 
    <seq id="mozart">
      <audio src="mozart1.wav"/>
      <video src=""/>
      <text src="mozart1.htm"/>
      <audio src="mozart2.wav"/>
      <video src=""/>
      <text src="mozart2.htm"/>


Microsoft, Macromedia, and Compaq have a multimedia alternative to SMIL called Timed Interactive Multimedia Extension (referred to as HTML+TIME), which is an XML application. Whereas SMIL documents let you manipulate other files, HTML+TIME lets you handle both HTML and multimedia presentations in the same page.

HTML+TIME is not nearly as powerful as SMIL, but Microsoft has shown relatively little interest in SMIL. You can find out about HTML+TIME at HTML+ TIME is implemented in the Internet Explorer as a behavior, which is a construct in Internet Explorer that lets you separate code from data. You can find more information about Internet Explorer behaviors at

Here's an example HTML+TIME document that displays the words Hello, there, from, HTML+TIME, spacing the words' appearance apart by 2 seconds and then repeating:

Listing ch01_10.html

      Using HTML+TIME
      .time {behavior: url(#default#time);}

    <DIV CLASS="time" t:REPEAT="5" t:DUR="10" t:TIMELINE="par"> 
      <DIV CLASS="time" t:BEGIN="0" t:DUR="10">Hello</DIV>
      <DIV CLASS="time" t:BEGIN="2" t:DUR="10">there</DIV>
      <DIV CLASS="time" t:BEGIN="4" t:DUR="10">from</DIV>
      <DIV CLASS="time" t:BEGIN="6" t:DUR="10">HTML+TIME.</DIV>

You can see the results of this HTML+TIME document in Figure 1-14.

Figure 1-14Figure 1-14 An HTML+TIME document at work.

HTML+TIME actually builds on SMIL to a great extent. The example from the previous topic on SMIL would look this way in HTML+TIME:

<t:seq id="mozart">
  <t:audio src="mozart1.wav"/>
  <t:video src=""/>
  <t:textstream src="mozart1.htm"/>
  <t:audio src="mozart2.wav"/>
  <t:video src=""/>
  <t:textstream src="mozart2.htm"/>

XML at Work: XHTML

One of the biggest XML applications around today is XHTML, the translation of HTML 4.0 into XML by W3C. It's attracting a lot of attention. I'll dig into XHTML in some depth in this book.

W3C introduced XHTML to bridge the gap between HTML and XML, and to introduce more people to XML. XHTML is simply an application that mimics HTML 4.0 in such a way that you can display the results—true XML documents—in current Web browsers. XHTML is an exciting development in the XML world, and we'll be spending some time with it later in this book.

Here are some XHTML resources online:

XHTML 1.0 comes in three different versions: transitional, frameset, and strict. The transitional version is the most popular because it supports HTML more or less as it's used today. The frameset version supports XHTML documents that display frames (this version is different than the transitional version because documents in the transitional version are based on the <body> element, whereas documents that use frames are based on the <frameset> element). The strict version omits all the HTML elements deprecated in HTML 4.0 (of which there were quite a few).

XHTML 1.1 is a form of the XHTML 1.0 strict version made a little more strict by omitting support for some elements and adding support for a few more (such as <ruby> for annotated text). You can find a list of the differences between XHTML 1.0 and XHTML 1.1 at

Here's an example XHTML document using the XHTML 1.0 transitional DTD. You can display this document in any standard HTML browser (note that tag names are all in lowercase in XHTML):

Listing ch01_11.html

<?xml version="1.0"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="" xml:lang="en" lang="en"> 
      Web page number one!

      Welcome to XHTML!
    This is simple text that appears in this page. 
        Here's a new paragraph!

You can see the results of this XHTML in Figure 1-15. Writing XHTML is a lot like HTML, except that you have to adhere to XML syntax (such as making sure that every element has a closing tag).

Figure 1-15Figure 1-15 Displaying XHTML.

XML at Work: Microsoft's .NET

Microsoft's .NET initiative is based substantially on XML, which it uses to send data back and forth between .NET components. In .NET, you don't usually see the XML—it's handled behind the scenes automatically—but it's there.

Here's an example in VB .NET that will expose the behind-the-scenes XML: The data in .NET datasets is transported using XML, and this example explicitly writes the authors database table of the pubs example database to an XML file when the user clicks a button. When the user clicks another button, the code reads that file back into a second .NET dataset. You can see this example at work in Figure 1-16 (which also displays the data in the authors table).

Figure 1-16Figure 1-16 Writing data in XML in VB .NET.

Here's the VB .NET code—when the user clicks the "Write existing dataset to XML file" button you see in Figure 1-16, the authors table in the dataset is written to the file dataset.xml; and when the user clicks the "Create new dataset from XML file" button, a new dataset is created and reads its data in from dataset.xml:

Private Sub Button1_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button1.Click
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button2.Click
  Dim ds As New DataSet()
  DataGrid1.SetDataBinding(ds, "authors")
End Sub

You can see the dataset's data in the dataset.xml file, which looks like this—it's pure XML (and matches the data you see in Figure 1-16):

<?xml version="1.0" standalone="yes"?>
<DataSet1 xmlns="">
  <phone>408 496-7223</phone>
  <address>10932 Bigge Rd.</address>
  <city>Menlo Park</city>
  <phone>415 986-7020</phone>

And that provides us with a glimpse at the actual XML used behind the scenes to transport data in .NET—something that's usually handled automatically.

XML at Work: Open Software Description

Open Software Description (OSD) was developed by Marimba and Microsoft, and you can find more about this XML application at OSD allows you to specify how and when software is updated via the Internet.

Not everyone thinks OSD is a great idea—after all, many users want control over when their software is updated. New versions might have incompatibilities with old versions, for example.

Here's an example .osd file that handles updates for a word processor named SuperDuperTextPro from SuperDuperSoft:

<?xml version="1.0"?>
    SuperDuperTextPro Updates
  <USAGE VALUE="SoftwareUpdate"/>
      SuperDuperTextPro version 206 with sideburns!!!

XML at Work: Scalable Vector Graphics

Scalable Vector Graphics (SVG) is another W3C-based XML application that is a good idea but that has found only limited implementation so far (notably, in such programs as CorelDraw and various Adobe products such as Adobe Illustrator). Using SVG, you can draw two-dimensional graphics using markup. You can find the SVG specification at and an overview at

Note that because SVG describes graphics, not text, it's harder for current browsers to implement, and are no browsers today have full SVG implementations. Other graphics standards have been proposed, such as the Precision Graphics Markup Language (PGML) proposed to the W3C ( by IBM, Adobe, Netscape, and Sun.

Here's an example PGML document that draws a blue box:

<?xml version="1.0"?>
<!DOCTYPE pgml SYSTEM "/DTDs/pgml.dtd">
 <group fillcolor="blue">
   <moveto x="0" y="0"/>
   <lineto x="0" y="1000"/>
   <lineto x="1000" y="1000"/>
   <lineto x="1000" y="0"/>

XML at Work: Vector Markup Language

Vector Markup Language (VML) is an alternative to SVG that is implemented in Microsoft Internet Explorer. You can find out more about VML at Using VML, you can draw many vector-based graphics figures; here's an example that draws a yellow oval, a blue box, and a red squiggle:

Listing ch01_12.html

<HTML xmlns:v="urn:schemas-microsoft-com:vml">

      Using Vector Markup Language

    v\:* {behavior: url(#default#VML);}

        Using Vector Markup Language
    <v:oval STYLE='width:100pt; height:75pt' 
      fillcolor="yellow"> </v:oval>
    <v:rect STYLE='width:100pt; height:75pt' fillcolor="blue" 
      strokecolor="red" STROKEWEIGHT="2pt"/>
      strokecolor="red" STROKEWEIGHT="2pt"/>

You can see the results of this VML in Figure 1-17.

Figure 1-17Figure 1-17 Vector Markup Language at work.

Extensible Business Reporting Language

Extensible Business Reporting Language (XBRL, formerly named XFRML) is an open specification that uses XML to describe financial statements. You can find more on XBRL at Using XBRL, you can codify business financial statements in a way that makes it easy to search them en masse and review them quickly, extracting the information you want.

Here's a sample XBRL document that gives you an idea of what this application looks like at work:

<?xml version="1.0" encoding="utf-8" ?> 
  <group xmlns="" 
    id="543-AB" entity="NASDAQ:GPSI" period="1999-05-31" 
    scaleFactor="6" precision="9" type="USGAAP:Financial" 
    unit="ISO4217:USD" decimalPattern="" formatName="">
    <item id="IS-025" 
    <item id="IS-026" 
  <group type="gpsi:detail.quarterly" period="1998-05-31">
    <item period="1997-06-01/1998-07-31">0.12</item> 
    <item period="1997-09-01/1997-11-30">0.16</item> 
    <item period="1997-12-01/1998-02-28">0.17</item> 
    <item period="1998-03-01/1998-05-31">-0.12</item> 
    <item period="1998-06-01/1998-05-31">0.33</item> 
  <group type="gpsi:detail.quarterly" period="1999-05-31">
    <item period="1998-06-01/1998-08-31">0.15</item> 
    <item period="1998-09-01/1998-11-30">0.20</item> 
    <item period="1998-12-01/1999-02-28">0.23</item> 
    <item period="1999-03-01/1999-05-31">0.28</item> 
    <item period="1998-06-01/1999-05-31">0.86</item> 
  <group type="gpsi:detail.quarterly" period="1998-05-31">
    <item period="1997-06-01/1998-07-31">0.11</item> 
    <item period="1997-09-01/1997-11-30">0.15</item> 
    <item period="1997-12-01/1998-02-28">0.17</item> 
    <item period="1998-03-01/1998-05-31">-0.12</item> 
    <item period="1998-06-01/1998-05-31">0.32</item> 


Resource Description Framework

Resource Description Framework (RDF) is an XML application that specializes in metadata—that is, data about other data. You use RDF to specify information about other resources, such as Web pages, movies, automobiles, or practically anything. You can find more information about RDF at; I'll be discussing it later in the book as well.

Using RDF, you create vocabularies that describe resources. For example, the Dublin Core is an RDF vocabulary that handles metadata for Web pages; you can find more information about it at Using the Dublin Core, you can specify a great deal of information about Web pages. The Dublin Core is designed ultimately to replace the unsystematic use of <META> tags in today's pages. When systemized, that information will be much more tractable to Web search engines.

Here's an example RDF page using the Dublin Core that gives information about a Web page:

<RDF:RDF xmlns:RDF=""
  <RDF:Description about=""> 
    <DC:Title>Welcome to XML!</DC:Title> 

Note that many more XML applications exist than can be covered in one chapter—and plenty of them work behind the scenes. As mentioned earlier, Microsoft's .NET initiative uses XML extensively internally. Microsoft Office 2000 and Office XP can handle HTML as well as other types of documents, but HTML doesn't allow it to store everything it needs in a document; thus, it also includes some XML behind the scenes (in fact, Office 2000 and XP's vector graphics are done using VML). Even relatively early versions of Netscape Navigator allowed you to look for sites much like the current one you're viewing; to do that, it connected to a program that uses XML internally. As you can see, XML is everywhere you look on the Internet.

And that's it for our overview chapter. We've gotten a solid foundation in XML here, and it's a good place to begin. The next step is to get systematic and to start getting all the actual ground rules for creating XML documents under our belts. I'll turn to that in Chapter 2.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.