In this tutorial I’ll continue to cover XML and all of it’s capabilities. XML stands for eXtensible Markup Language. I hope you got this one point from the last XML Article. XML does one thing really well. It organizes and classifies your data, so that it is useable by a wide range of devices and software packages!
In this article I’ll explain how XML influenced HTML, to create the newest version of HTML called XHTML. I’ll then explain what well formed XML is and Document Type Definition’s (DTD).
Why Do we Need XHTML?
I wrote a whole article on the difference between HTML and XHTML. You may prefer to read that for a more in-depth discussion, but here I’ll cover all the most important points.
Why is XHTML now widely used? One simple reason. HTML provided people with the ability to display information in browsers. XHTML opened up the possibilities of providing content on many more internet output devices.
By using XHTML you will also find it easier to connect with databases and other structured data. And, because XHTML is highly structured you can better guarantee that your information will be displayed exactly the way you want it.
How to Turn HTML into XHTML
More on the DOCTYPE
Oh, bad things happen when you don’t define a DOCTYPE! If a browser doesn’t see a DOCTYPE defined, it will layout your website based on what is called Quirks Mode. This means your web page will look completely different on every browser and more than likely will look broken to anyone that visits your site.
In the DOCTYPE above you can see the words xhtml1-transitional.dtd. This signals to the browser that it should expect your web page to follow the rules described in that Document Type Definition. A DTD specifies what tags and attributes are allowed in your web page markup.
There are two possible DTD’s you can define in XHTML. If you are going to only style your pages with Cascading Style Sheets (CSS), use xhtml1-strict.dtd. If you may use HTML for presentation in anyway, stick with transitional.
Well-Formedness, Yes it’s a Word
Do you want your XML to be processed? If so your XML Markup must be what is called Well-Formed. That just means, it can’t violate any rules established in XML doctrine. If you do break any rules the XML processor while cease the processing of your XML Markup.
What Rules Must your XML Follow to Be Well-formed?
Document Type Definition’s (DTD)
You create a Document Type to define the rules that must be followed in your XML Markup. A DTD defines what elements are required and what attributes can be set and what their potential values can be. You are now entering the next level of XML Development!
Probably the most important question you can ask about DTD’s is, do you need one? If you are only creating small XML files, the answer is probably not. If however you are working with large sets of data that require very specific usage, the answer is probably yes.
DTD Jargon
Here is some jargon you must understand to get DTD’s:
That’s All Folks
In the next article I’ll completely describe how to create DTD’s. If you have any questions leave them below.
Till Next Time
-Think Tank
Leave a Reply