Here is a mind map of "SAMS Teach Yourself XML in 21 days" by Steven Holzner.
"XML is all about storing your data. ... XML is not about displaying your data - it's about packaging that data to transport it easily." [p. 10]
"... the languages designed to let you store and handle text are called markup languages, and there are plenty of them out there." [p. 10]
One example of a markup language is HTML. The markup tells the browser how to interpret the data. The markup is made up of tags such as <HEAD>, <BODY>. However HTML is a very limited language and is no longer recommended for use in creating web pages. The real difficulty is creating a language that has enough tags to do the numerous different activities that one might want to do. The whole idea behind XML is to let you create your own markup.
"XML is meant for storing data, not displaying it." [p. 12]
"XML is a creation of the World Wide Web Consortium (W3C). ... XML version 1.0 is in recommendation form, and has been since October 6, 2000, which means its an established standard." [p. 13]
I have just checked the W3C web site ( www.w3.org ) and noted that XML version 1.1 is now in recommendation form since August 16, 2006. |
All XML documents begin an XML declaration that specifies which version of XML is used in the rest of the document.
Using Dreamweaver, if one creates a new XML document, the first line of code is automatically created:
<?xml version="1.0" encoding="ISO-8859-1"?>
I will try changing this to version 1.1 when I have a good example in hand and see if it makes any difference.
|
Now that I have a line of code, it is time to look at the syntax.
<?xml?> is called a declaration (it declares which version of xml is being used) and has 2 attributes, version and encoding. Each attribute is given a value by using an equal symbol and then enclosing the value in double quotes.
An element is the fundamental unit that you use to hold your data. Elements always start with an opening tag and end with a closing tag. You create an element by pairing an opening tag with a closing tag. (e.g. <stuff>...</stuff>).
"You're free to make up your own element names in XML, and that's XML's whole power - the capability to create your own markup." [p. 15]
I just tried previewing the following XML file in both Firefox 2.0 and Safari 2.0.4. Safari worked fine, but Firefox gave an error message on xml version="1.1". Interesting.
<?xml version="1.1" encoding="ISO-8859-1"?>
<stuff>data</stuff>
I also tried using Microsoft Internet Explorer and it also failed to process the file: no error message but also no display. Clearly the world is not yet ready for version 1.1. |
"An element's content can be made up of simple text or other elements. Like XML declarations, XML elements can support attributes. ... When you create an XML document, you must enclose all elements inside one overall element, called the root element. " [p. 16]
"Being able to create your own elements from scratch like this has advantages and disadvantages - you're not restricted to a predefined and limited set of tags, but on the other hand, a standard Web browser can understand HTML tags but will have no idea what to do with a user-defined tag." [p. 17]
You can store your data in an XML file and then display it using a separate document called a style sheet. Style sheets can be interpreted by most Web browsers. Thus one needs to learn to create 2 types of file: an XML file that contains the data and a style sheet file that reads the XML file and recodes it into XHTML which can be read by a Web browser.
"There are two kinds of style sheets you can use with XML documents - cascading style sheets (CSS), which you can also use with HTML documents and Extensible Stylesheet Language style sheets (XSL), designed to be used only with XML elements." [p. 18]
A style sheet file simply contains a few statements of the form selector {property1: value; property2: value}. The selector identifies the element that the declaration will apply to.
Here is a schematic image of what I have covered so far:
"An XML document actually can do more than just hold your data; it can let you specify the structure of your data as well." [p. 24]
"There are two main checks that XML processors make: checking that your document is well-formed and checking that it's valid. ... Informally, the main requirements [being well-formed] are that the document must contain one or more elements, and one element, the root element, must contain all of the other elements. In addition, each element must nest inside any enclosing properly. ... An XML document is valid if it adheres to the syntax you've specified for it, and you can specify that syntax in either a Document Type Definition (DTD) or an XML schema." [p. 25]
QUIZ
1. What's the main reason XML has become so popular in the last five years?
XML files are text files that can be easily sent over the Internet.
2. What are the four different types of specifications that W3C publishes?
notes, working drafts, candidate recommendations, recommendations
3. What's an XML element? What's an XML attribute?
An XML element is a name that begins with an opening tag and ends with an closing tag, and which may contain some data between them. Example: <name>Dale</name>.
An XML attribute is a property that may take specific values. Example: font-size="14".
4. What are some of the requirments for an XML document to be well-formed?
There must be at least one root element which contains all of the other elements. Every element must have both an opening and a closing tag. All tags must be properly nested within one another.
5. What are two XML constructs that let you specify an XML document's syntax so it can be checked for validity?
A Document Type Declaration (DTD) or an XML schema.
|