spacer

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

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

HTML Unleashed: The Emergence of XML

Well-Formed XML Documents

 
 

If you're scared by the prospect of learning the art of writing document type definitions, there's a good news for you: with XML, you can create a document even without DTD.  If the lack of a DTD is the sole violation of XML requirements, such a document is called well-formed, as opposed to a valid document that has a DTD attached (or referred to).  Thus, well-formedness is the lower of the two levels of XML conformance, but although it is inferior to validness, it is still very useful.

The permission to omit the DTD means, in essence, that you are free to use any tags that seem necessary for your document.  You may just go wild and write in plain English what each part of your text is supposed to represent---for example, if you're a grammarian:

<SENTENCE>
  <SUBJECT TYPE="COMPLEX">
    <ARTICLE TYPE="INDEFINITE">A</ARTICLE>
    <ADJECTIVE>quick</ADJECTIVE>
    <ADJECTIVE>brown</ADJECTIVE>
    <NOUN>fox</NOUN>
  </SUBJECT>
  <VERB TYPE="INTRANSITIVE">jumps</VERB>
  <PREPOSITION>over</PREPOSITION>
  <ARTICLE TYPE="INDEFINITE">a</ARTICLE>
  <OBJECT>
    <ADJECTIVE>lazy</ADJECTIVE>
    <NOUN>dog</NOUN>
  </OBJECT>
</SENTENCE>

Given this well-formed document, an XML parser will be able to break the text into the elements that you deemed essential in this case and pass each element to the application along with its name (derived from the tag name) and attribute information you provided.  It is the application, not the XML parser, that must be programmed to perform some useful tasks with this structured information.  Most often, you'll need to provide the application with a style sheet that associates certain formatting parameters with each element (in our example, the style sheet might specify displaying different parts of speech in different colors).

In fact, even the "plain English" mentioned above is not an obligatory requirement for your tags.  Creators of XML intended that the language must be international from the very beginning.  They painstakingly identified all Unicode characters that may be called "letters" in some sense or in some language and included these characters into the set of characters allowed in element and attribute names.  This means that you can write your tags in Russian or Chinese instead of English.

There are, of course, numerous restrictions that are imposed even on well-formed documents.  Some of these requirements are even stricter than those of HTML and thus deserve special attention:

  • In XML, every start tag must have a corresponding end tag (unless it is an empty tag that takes special form, as described in the next item).  Tags should be properly nested; that is, you can't have an open tag within the scope of some other tag and the corresponding end tag outside that scope.

  • If a tag is empty by its nature (in other words, the corresponding element can never contain any text), it must have a forward slash (/) before the closing greater than symbol (>), for example:
    <IMG alt="XML logo" 
         src="http://www.ucc.ie/xml/xml.gif"/>
    

    Such tags are the only tags that do not have corresponding end tags.

  • All attribute values without exception must be enclosed in quotes (either single quotes ('') or double quotes ("")).

In fact, the preceding requirements are the only ones that you must satisfy to make your HTML files well-formed XML.  It doesn't matter which browser's HTML extensions you use or whether you "abuse" HTML tags or not.  XML is a truly liberal language; it makes you a creator of your own universe whose rules you're unlikely to break simply because it's you who establishes them.

Those familiar with the material in Chapter 3 may be wondering, what about another essential part of any SGML application, the SGML declaration that always accompanies a DTD? Because XML is pretty much simplified compared to SGML, its authors decided to omit this part of the language; XML parsers (or SGML software processing XML documents) should behave as if all XML documents were assigned the same generic SGML declaration that is listed in an appendix to the XML standard.

 

Produced by Dmitry Kirsanov
Copyright Sams.net Publishing 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

Created: Jun. 15, 1997
Revised: Jun. 16, 1997

URL: http://www.webreference.com/dlab/books/html/38-2.html