This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
tag in an XML document may not indicate a paragraph, it can mean anything depending on the context. XML is text, but it is not meant to be read. Most applications such as spreadsheets store data in a binary format. XML files are always human readable text, which usually does not need to be read, but can be if a problem arises. XML is verbose by design. XML uses a text format which tends to use more disk space than binary formats for data, however, both disk space and memory are cheap and if required XML files can be compressed using a zip program. In addition, communications programs such as HTTP/1/1 can compress data before transmission and decompress it after transmission. XML is a family of technologies. It defines the common framework of all XML based documents. It includes a growing set of modules which offer additional services such as Xlink and XPointer. XLink specifies a common way of adding hyperlinks to any XML document. XPointer is a way of pointing to data inside an XML document. CSS, which describes style sheets for formatting documents, is applicable to all XML based documents not just XHTML. In addition, the DOM provides a standard set of methods if you wish to work with any XML based document using a programming language. XHTML has many of the same features as HTML, but its syntax has been changed to comply with the rules of XML. XHTML uses the syntax rules of XML, but adds meaning to that syntax, for example, the XML syntax defines that
is an element, XHTML gives a meaning to this and says that it stands for 'paragraph'. XML is license-free, platform-independent and wellsupported. By using XML you will have access to a large and growing pool of widely supported tools.
What is XHTML? XHTML is the successor to HTML and follows the syntax and requirements rules of XML. While it appears to be similar in syntax to HTML there are some important differences. Before we look at creating an XHTML document it is important to look at some terminology, in particular the terms tag, element and attribute and also the syntax rules for XML, which also apply to XHTML, since it is an application of XML.
Tags, elements and attributes XHTML is an application of XML and therefore XHTML uses XML terminology, in particular the terms: • • •
element; tag; attribute.
There are two types of elements: non-empty and empty elements. A non-empty element consists of an opening and closing tag and data which is placed within the tags, for example in Figure 2.1: element name
+ t
element name
+
<pre>This text is displayed opening tag
Figure 2.1 Elements, tags and attributes. The name of the element is pre.
t
closing tag
The opening tag consists of the element name enclosed within the angled brackets: <pre>. The closing tag is the same as the opening tag except than the element name is preceded by the I character: The data is the text enclosed within the opening and closing tags. Empty elements do not have a closing tag, for example:
This element moves to a new line. You can add attributes to the opening tag of many elements. Attributes are qualifiers which specify some non default behaviour. They always consist of a name-value pair, for example:
This shows the opening and closing tags of the a element. The opening tag has one attribute. The name of the attribute is href, the value assigned to it is: http://www.essential-series.com/. There may be more than one attribute. Empty elements may also have attributes, for example:
!I1l!l!!!¥i¥ :
XML rules
...
The rules for writing XML and therefore XHTML elements are stricter than for HTML documents. •
XHTML is case sensitive. All tags must be written in lower case letters, for example:
•
Every non-empty XHTML element must have a closing tag, for example:
;