Article

Introduction to XML

Page: 1 2 3 4 5 6

XML in Action

Now you're up to speed with XML in general, what are these acronyms that keep popping up like XML Schema and XSLT? And what can you use XML for, anyway?

I'll give you a quick run down of the important "add-ons" and applications XML is now used for, some of which will be discussed in detail in other articles, as part of SitePoint's XML Week.

XML Validation

We've seen how to create well formed XML documents by obeying the basic rules of the W3 standard. What we haven't seen is how to validate the structure of an XML document and the data within it. If you receive an XML document from someone else, it may well be well formed -- but is the document actually relevant to the situation at hand? In HTML terms, the example below is well formed but it won't amuse many Web browsers.

<head>      
 <body>      
   <title>      
     <tr>      
       <td>This is almost XML!</td>      
     </tr>      
   </title>      
 </body>      
 <html>      
   <table> Almost an XML Page </table>      
 </html>      
</head>

The first technology to deal with this was the DTD, part of the original XML specification. DTD's provide a means to validate the structure of an XML document, as well as providing information as to how the document should be processed and the ability to define custom entities. What DTD's don't provide is a means to validate the data stored in an XML tag. DTD's are also not themselves XML. As a result, they are gradually being superceded by a new approach called Schemas.

There are two main (alternative) standards for validating XML; the W3's XML Schema and Relax NG. Although Relax NG is arguably easier to use, the W3 XML Schema standard seems to be gaining greater support as the de facto XML validation technology. Both of these provide the ability to validate not just the structure of an XML document, but also the data stored in it -- and go so far as to provide regular expressions for the purpose.

XHTML

Simply put, XHTML is just HTML that conforms to the rules of well formed XML. In other words, it's <img src="myimage.png" /> from now on.

XML Namespaces

XML namespaces are used to create a single document with multiple (and potentially overlapping) XML tag sets. They allow an XML parser to identify which set a tag belongs to, and as a technology, this is particularly important to SOAP-based Web services, XML Schema and XSLT (see below).

XSL(T)

XML Stylesheets are a mechanism that allow an XML document to have a set of "rules" applied to it, based on tag name, in much the same way as Cascading Stylesheets allow you to specify a particular "look" for a particular HTML tag. XML Stylesheets get most interesting when used in transformations (XSLT). XSLT can be used to transform an XML document into another XML document, and represents a very important technology for Web designers and developers to learn.

Given some XML, you could use XSLT to convert it to any of XHTML, WML (Wireless Markup Language), SOAP, XML-RPC, SVG (see below) or even Flash and PDF (with the aide of a little PHP or otherwise) files. That means you can deliver multiple user interfaces from a single data source...

You could also use XSLT to transform between SOAP and XML-RPC (two of the Web services standards).

XPath

XPath is a mechanism for navigating an XML tree using a syntax that's similar to the command line access of a file system in DOS or a UNIX shell. XPath is important for XSLT.

XLink

Allows you to place HTML-like links in XML documents that take advantage of XML namespaces. XLink may have flopped as a technology, perhaps given that most people would rather transform XML into XHTML, rather than read raw material itself. XLink is still significant though, as a step towards XPointer...

XPointer

XPointer takes advantage of XPath and XLink to provide a mechanism to point to a specific tag or range within another XML document. As XML evolves from being simply a markup language to something that resembles a programming language, and for use in XML storage (XML databases) XPointer is likely to become more important. It's one for the developers to watch.

Web Services

Web services have been examined at SitePoint in Web Services Demystified and Build your own Web Service with PHP and XML- RPC. XML-RPC was the "original" XML messaging standard, with another early alternative being WDDX. The current king of Web services is the SOAP XML standard.

WML

Wireless Markup Language is an XML standard for wireless devices developed by a consortium of mobile device vendors. More information at http://www.wapforum.org/ (basically the XHTML equivalent for WAP/3rd Generation mobile devices).

SVG

Scalable Vector Graphics allow you to draw graphics using XML, relying on the Web browser to display the end result, including animation. There's a collection of demos here, including a map of Vienna and an animated chess game. For PHP developers there's an excellent SVG class library here, along with an SVG Graphing Tool.

XML Elsewhere

Other XML applications have been built for all kinds of things, from B2B ecommerce with ebXML to Mind Reading Markup Language (I kid you not). The the most comprehensive list I've come across is at Oasis: http://xml.coverpages.org/xmlApplications.html (prepare to fall over backwards reading that), or if you don't like lists, try this poster.

A particularily interesting area of development right now is in the arena of XML data storage (databases). The "traditional" database vendors like Microsoft and Oracle have already climed aborad the bandwagon, adding XML support to their products. Meanwhile a whole new generation of databases in is progress, such as Apache's Xindice. This area of database development is still "work in progress" but, in theory, XML presents a better alternative to SQL for "exploring" and relating data, as well as data types you won't see in most databases. It also offers potential benefits such as native database Web services and "document based" data storage, perhaps making user interface generation an easier task. There's a more in-depth discussion here.

Otherwise, a good place to get un-hyped and accurate XML news is xmlhack.

Tagged and Bagged

Hopefully you now have some idea of what XML is about and why it's important to all of us building the Web. Do I hear you saying "It's so easy!"? If not, please feel free to drop by the SitePointForums discussion below with any questions. For the rest of SitePoint's XML week you'll be treated to an in-depth view of some of advanced XML technologies and application. Enjoy!

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: