spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / new / xml

X(ML) Marks the Spot

Developer News
Sir Tim Talks Up Linked Open Data Movement
From L.A. to Vegas With 100GbE
Salesforce Rolls Out Big Summer '08 Update

Never before has an Internet development witnessed such rave reviews before thorough implementation and testing as the eXtensible Markup Language (XML). XML is definitely the latest buzzword in the developer community. However, you must crawl before you can walk. The idea of creating an XML based e-commerce solution is exciting, but what about a simple XML page which has standard Web media elements such as graphics or Flash files?

XML promises to give us intelligent document structures, object oriented document manipulations, synchronized media and a whole lot more. But what is XML exactly, and why has it created such a stir? This article is for those developers who are looking for a hands-on explanation of XML basics.

What is XML?

The eXtensible Markup Language and HTML are both subsets of Standard Generalized Markup Language (SGML). SGML is a very powerful technology that can be viewed as the parent of many markup languages, which include HTML and XML. With XML, it is possible to create new variations such as the Wireless Application Protocol Markup Language (WAPML or WML), which makes communicating and transactions between a mobile phone and a Web server possible.

Of all the aspects of XML, the following is probably the most important: XML only recently became an official W3C recommendation. This means that the consortium still hasn't made a decision about standard XML. Many XML elements used in Explorer 5.0 are based on the W3C draft and they will probably be included in the official XML specs. Netscape has probably made the wise decision to wait with releasing their XML compliant version 5 browser until the official specs have been determined.

Enough background information. Let's get into the real deal. The big difference between XML and HTML is the following: an HTML document has three different elements: The first element being the text (e.g. "Welcome to my homepage"). The second element is the document structure such as tables and linebreaks. The third element is the visual markup such as bold text, italic text, graphics and other visual elements.

An XML document, however, can actually consist of two or three different pages. Because seeing is believing, I've included a short example below.

1. The first page is the actual XML information you wish to display. In first generation XML sites, this information will probably be text contained in the page called "whatever.xml". This page doesn't have any structure such as a table or visual markup (bold, italic or color).

Whatever.xml looks like:

<?XML version="1.0" ?>
<?XML-stylesheet type="text/xsl" href="whatever.xsl"?>
<people>
 <friend>
  <name>Lee</name>
  <address>25 Malvern street</address>
  <telephone>123 456 789</telephone>
 </friend>
 <friend>
  <name>Susanna</name>
  <address>11 Durban road</address>
  <telephone>987 654 231</telephone>
 </friend>
</people>

2. The second page has the Extensible Stylesheet Language (whatever.xsl). This page has HTML and "tags" which takes the data out of whatever.xml and puts into "whatever.xsl". The xsl document has the mark-up such as <body>, <table> and <font>.

Whatever.xsl looks like:

<?XML version="1.0"?>
<xsl:stylesheet XMLns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML>
 <head><title>XML Developer</title></head>
<body>
 <table border="1" cellpadding="3" cellspacing="3">
 <xsl:for-each select="people/friend">
<tr>
   <td><b>Name:</b><br/></td>
   <td><xsl:value-of select="name"/></td>
 </tr>
 <tr>
   <td>Address:<br/></td>
   <td><i><xsl:value-of select="address"/></i></td>
 </tr>
<tr>
   <td>Telephone:<br/></td>
   <td><i><xsl:value-of select="telephone"/></i><br/></td>
 </tr>
</xsl:for-each>
</table>
</body>
</HTML>
</xsl:template>
</xsl:stylesheet>

3. The third page is the Document Type Definition. The good news is that a DTD is not always necessary, especially in a simple XML document. The bad news is that a DTD is pretty darn difficult. It contains elements such as attributes and data types. For more information on DTDs, take a look at:

http://www.webref.com/authoring/languages/xml/questions/dtd.html

The XML version of linebreak is <br/> instead of the HTML <br>. Herein lies the secret in getting around the most common and frustrating markup language bugs [or features, depending on your point of view -eds.], which go by the name of validity or "well- formed code." In the good old Internet days, developers were very meticulous when it came to their coding. If you opened a <font> tag, you'd have to close it with </font>. When browsers got smarter, coders became lazier. As HTML evolved, people also decided that it wasn't necessary to include certain quotes in their code. So what was once <font color="white"> became <font color=white>. And then XML hit the scene.

Next: XML Needs Clean Code

This article originally appeared in the December 2, 1999 edition of the WebReference Update Newsletter.


http://www.internet.com

Comments are welcome
Written by Leroyson Figueira and

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
Book Review: Head First JavaScript · Web Hosting Control Panels · Use Your Blog for Fast Search Engine Rankings
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
NetApp's Virtual Storage Strategy Crystallizes · F/MC Watch: A Cisco-Centric Approach · Olympic Time Trials Use Wi-Fi Mesh

Revised: May 16, 2000

URL: http://webreference.com/new/xmlintro.html