|
|
- You know that XHTML
is, in essence, HTML that follows the rules or syntax of XML (extensible
markup language). The most important of those rules are:
- Tags
must be lowercase
- All
non-empty elements must have closing tags (e.g. </p>)
- All
empty elements must have a closing slash (e.g. <br />)
- All
values of attributes must be quoted (e.g. <tag attribute="value">
- All
tags must be properly nested (e.g. <b><i>Some bold, italic
text </i> </b>
- As we've said, you
must also add a document-type declaration to the XHTML file:
<!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1l/DTD/transitional.dtd"> and
add reference to the XHTML namespace in the <html> tag:
<html xmlns="http://www.w3.org/2010/xhtml">
- SO,
what is XML? Here is a page that summarizes
a first look at XML. There are lots of deep forums, but here's an FAQ
page for later, and one place for a good overview
and tutorials.
- Here is a sample
XML page. Note the syntax (and the fact that browsers can read it). The +/-
are to collapse tags.
- Here is a first
page I built that qualifies as "well-formed."
recall from the review that that means it follows the rules of XML (or
XHTML) syntax.Your assignment for right now is to create a similar page
in Notepad or TextEdit for an address book (a common XML file), a news and events page, a publications page, a staff list, a menu, etc. that has at least
three entries.
- Next, here is the
same file that now qualifies as a valid
document because it has an internal DTD (document type definition)
which tells the browser where to find the rules, if any, for interpreting
the tags. Note that the DTD rules are apparent only in the source code.
To check those you would need an XML parser like the one here,
but it needs to be on a local drive, not the Web server. Also XML schemas are replacing DTDs.
- XML can be styled
with XSL or CSS. Here is a Version of Twelfth
Night styled with CSS (be sure to take a look at the CSS
file). There is nothing new there for you. For you to style your
file from step 5., you should declare the document as standalone
(<?xml version="1.0" standalone="yes"?>) as
in step 6. You could create a DTD (or better, a schema), thus making it a valid XML
document. Then you could add a CSS stylesheet (<?xml-stylesheet
type="text/css" href="mystyle.css"?>) or use XSLT (see handout).
- Finally,
here is a page that generates
HTML, with attributes, with the XSL file
built using XSL (eXtensible Stylesheet Language) which
includes XSLT, a means of Transforming XML into HTML, PDF, etc. This
tutorial gives
a brief introduction, and you can check out zvon.org.
|