Learning XML shows the purpose of XML markup itself, the CSS and XSL styling in the late 90s, Extensible Markup Language (XML) has unleashed a torrent of new takes care of the second misconception, that XML will replace HTML. This second edition of the bestselling Learning XML provides web developers with a concise but grounded understanding of XML (the Extensible Markup. The second edition, which merely incorporates error corrections and clarifica- tions and . As you'll learn, you can write an XML document to conform to either.
|Language:||English, Spanish, Dutch|
|Genre:||Academic & Education|
|Distribution:||Free* [*Registration Required]|
Learning XML 2nd Edition Erik T Ray Published by O'Reilly and Associates reviewed by Lindsay Marshall in the December issue (pdf), (html), bookcover. Download Learning XML, 2nd Edition (Erik T. Ray) Download free online book chm pdf. This small book combines a perfect tutorial for learning the basics of XML The new edition introduces information on XSLT (Extensible Stylesheet. Language.
What a time-saver! More than Structure… XML documents are more then just a sequence of elements. The documents are really a hierarchy of nested objects. This feature, combined with all that content encapsulated in opening and closing tags, takes all XML documents far past the realm of mere data and into the revered halls of information.
Data can comprise a string of characters or numbers, such as But the only way to turn this data into information and therefore make it useful is to add context to it — once you have context, you can be sure about what the data represents.
When you take into account the second point — that an XML document is really a hierarchy of objects — all sorts of possibilities open up. Remember what we discussed before — that, in an XML document, one element contains all the others?
Well, that root element becomes the root of our hierarchical tree. You can think of that tree as a family tree, with the root element having various children in this case, product elements , and each of those having various children name, description, and so on.
In turn, each product element has various siblings other product elements and a parent the root , as shown in Figure 1.
Figure 1. The logical structure of an XML document. Because what we have is a tree, we should be able to travel up and down it, and from side to side, with relative ease.
Before, we talked about transforming data into information by adding context. Formatting Issues Earlier in this chapter, I made a point about XML allowing you to separate information from presentation. For example, if you stored your information in a word processing program, it would contain all kinds of information about the way it should appear on the printed page — lots of bolding, font sizes, and tables.
Unfortunately, if that document also had to be posted to the Web as an HTML document, someone would have to convert it either manually or via software , clean it up, and test it. If yet another person wanted to take the same information and use it in a slide presentation, they might run the risk of using outdated information from the HTML version.
As you can see, it can get pretty messy! If you made changes to the XML file, the other files would also change automatically once you passed the XML file through the process. This notion, by the way, is an essential component of single-sourcing — i. As you can see, separating information from presentation makes your XML documents reusable, and can save hassles and headaches in environments in which a lot of information needs to be stored, processed, handled, and exchanged.
That means the publisher can generate sample PDFs for its Website, make print-ready files for the printer, and potentially create ebooks in the future. All formats will be generated from the same source, and all will be created using different style sheets to process the base XML files. One of the most powerful advantages of XML, of course, is that it allows you to define your own language. However, this most powerful feature also exposes a great weakness of XML.
If all of us start defining our own languages, we run the risk of being unable to understand anything anyone else says. All elements must be properly nested. All attribute values must be quoted. A valid document, then, is nothing more then a well-formed document that adheres to its DTD. The question then becomes, why have two levels of legality? A good question, indeed!
For the most part, you will only care that your documents are well formed.
Well-formedness alone allows you to create ad hoc XML documents that can be generated, added to an application, and tested quickly. The bottom line? Well-formedness is mandatory, but validity is an extra, optional step. The first thing we want to do is to create an XML document. Here it is again, with a few more nodes added to it: Example 1. It really is as good as we say it is--or your money back.
As Figure 1. Notice the little minus signs next to some of the XML nodes?
A minus sign in front of a node indicates that the node contains other nodes. If you click the minus sign, Internet Explorer will collapse all the child nodes belonging to that node, as shown in Figure 1. Collapsing nodes displaying in Internet Explorer.
View larger image. The little plus sign next to the first product node indicates that the node has children. Clicking on the plus sign will expand any nodes under that particular node. In this way, you can easily display the parts of the document on which you want to focus. Now, open your XML document in any text editing tool and scroll down to the cost node of the second product. You should see an error message that looks like the one pictured in Figure 1.
Error message displaying in Internet Explorer. Furthermore, it provides a nice visual of the offending line, a little arrow pointing to the spot at which the parser thinks the problem arose. Because Internet Explorer uses a non-validating parser by default remember, this means it only cares about well-formedness rules , it runs into problems at the end tag. You now have to backtrack to find out why that particular end tag caused such a problem. Open your XML document in an editor once more, and fix the problem we introduced above.
Save your work and reload your browser. You should see an error message similar to the one shown in Figure 1. Debugging a more complex error. At first glance, this error message seems a bit more obscure than the previous one. However, look closely and what do you see? Firefox is a popular open-source browser, and at the time this book went to print the latest version was 1.
You can download a free copy from the Mozilla website. How do you do that? Well, there are a couple of options, listed below. All you have to do is visit the appropriate page, upload your document, and the parser will validate it.
Here is the most popular online parser.
What can and can t you do with XML? What s the history that led us here? And what tools do you need to get started? Next, he introduces the basic building blocks of XML markup and all XML-derived languages: stuff you ll need to know regardless of your goals.
Through easy examples, you ll understand elements, attributes, entities, and processing instructions -- and how they fit together in a well-formed XML document. Then, it s on to representing information with XML -- in other words, understanding the nature and planning the structure of the documents you ll be using. Ray starts simply, then builds on his basic examples to discuss narrative documents with text flows, block and inline elements, and titled sections.
Once you can handle those, he discusses more complex information modeling, as used in specialized markup languages such as VML.
This edition contains an entirely new chapter on XML Schemas -- what he calls the shepherds that keep documents from straying outside of the herd and causing trouble. Schemas, of course, have become hugely important. This is one of the best plain-English introductions to the topic we ve seen.
Ray then turns to presentation, introducing CSS stylesheets, basic usage, rule matching, properties, and more. A little later on, he returns to the subject -- this time with a complete introduction to XSL-FO that illuminates two powerful examples.
The second is the immensely powerful DocBook -- which, as we ve observed, Ray knows inside and out. Learning XML is superbly written.