Index Page Page 1 Page 2 Page 3 This Page Page 5 Page 6 Homework

Martha's COIN 74 Week 8 Exercises

Day Four - XHTML

SOURCE: Robert D. Cormia's online text
my comments in blue

Martha's First XHTML
this is more surprising than it seems!

XHTML DOCUMENTS

XHTML - okay so now you really want to put your knowledge to the test. In this section you will build an XHTML document. So what *is* XHTML? Very simply, it's HTML seen through the eyes of XML. Which means 1) having a proper DOCTYPE definition, 2) being well formed, and 3) having a validating DTD. Before diving into the short section below, first try looking at the W3C specification http://www.w3.org/TR/xhtml1/ We need to read up on XHTML transitional too.

What is XHTML Transitional?

XHTML Transitional is a version of XHTML which allows you to employ styling in your HTML. In contrast, XHTML Strict requires all styling to be done using CSS. There are separate DTD's for each version. The DTD's enforce conformance to these rules. It is therefore easier to convert existing HTML to XHTML Transitional than to XHTML Strict.

YOUR FIRST XHTML DOCUMENT

  1. Start by going to the File menu, and start a new file, but check the box in the lower right hand corner for making XHTML compliant. This starts are journey into slightly uncharted territory, as you'll see in the sections below.Name your first file something like xhtml_1.xhtml. Take a look at my reference file if you have any doubts. Now look at the same file, slightly rearranged, and saved as an actual .xml file, xhtml_1.xml Note that you'll need to have an Internet connection open in order to view this file.
  2. The transitional DTD. To view this file, click of xhtml1-transitional.dtd Note that you can't actually see this file in a browser, and some browsers will balk at the file. There are entities and other documents that are connected to this file, that need to be loaded as well. Is there a simple way to cheat? Well yes - try using the format below.
  3. Try looking at xhtml_2.xml, where I've commented out the DOCTYPE declaration. Now we can build some actual documents with an .xml file extension, and or just save our work with an .xhtml file extension. Sound confusing?
  4. For anyone running a validating XML parser / editor, you'll see that *both* .xhtml files are valid, and additionally, so is xhtml_1.xml. So what should *you* do? We'll simply work from .xhtml files from here on out.
  5. Stuff and bother. So what is all this namespace stuff about? <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> It simply means that there is a definition of what XHTML is, and that definition lives at, or is defined by, the URL http://www.w3.org/1999/xhtml There are more complicated definitions of course. If you'd like to venture there, please take my XML class.
  6. So where should you start, if you want to be writing XHTML? Well try looking at this file, xhtml.xhtml XML Spy made this file, after downloading the DTD. What can you do with it? Well, just populate it with HTML tags.

EXTENDING YOUR XHTML DOCUMENT

  1. This may sound dumb, but the whole point of XHTML is extending HTML, meaning adding other elements(tags) into it. So try taking a look at ISBN.xml. Wait a minute - that's XML - I lied! Or did I? Look carefully at <p xmlns="http://www.w3.org/1999/xhtml">This is also available <a href="http://www.w3.org/">online</a>.</p>
    and you'll see that I embeded HTML into an XML document. Okay, even more confusing.
  2. Take a look at math.xhtml and you'll see that you *can* extend XHTML, but it's a little tricky. In fact, this example, which appears on the W3C website, is actually *wrong*. We need to alter the DTD to alter the XML.
  3. So - just give me a real working example you say. Try stylesheet.xhtml - now this should get you thinking!
  4. Adding meta data - now this is where the whole tutorial becomes mind bending. You can actually create your own meta data to make your HTML document more 'self-describing'. This is actually a bit 'forward looking' and you'll need to think more like an advanced search engine, but in time these suggestions will all make sense.

WHERE ARE THE DTDS FOR VALIDATING AN XHTML DOCUMENT?

If you want to download the DTD's used to validate XHTML, you may find them using the following links:

WHERE CAN YOU SEE EXAMPLE XHTML DOCUMENTS?

Well - this is a bit harder, but I've tried to cobble together some links:

SOME SAMPLE XML, XHTML, and RSS FILES


Page Created 11/23/06     Assignment Submitted xx/xx/06
Document Last Modified:
© mjraup 2006
Webmaster