25-05-2012, 12:30 PM
XML
07-xml.ppt (Size: 136 KB / Downloads: 25)
HTML and XML, I
XML stands for eXtensible Markup Language
HTML is used to mark up text so it can be displayed to users
HTML describes both structure (e.g. <p>, <h2>, <em>) and appearance (e.g. <br>, <font>, <i>)
XML is used to mark up data so it can be processed by computers
HTML and XML, II
HTML and XML look similar, because they are both SGML languages (SGML = Standard Generalized Markup Language)
Both HTML and XML use elements enclosed in tags (e.g. <body>This is an element</body>)
Both use tag attributes (e.g.,<font face="Verdana" size="+1" color="red">)
Both use entities (<, >, &, ", &apos
More precisely,
HTML is defined in SGML
XML is a (very small) subset of SGML
HTML and XML, III
HTML is for humans
HTML describes web pages
You don’t want to see error messages about the web pages you visit
Browsers ignore and/or correct as many HTML errors as they can, so HTML is often sloppy
XML is for computers
XML describes data
The rules are strict and errors are not allowed
In this way, XML is like a programming language
Current versions of most browsers can display XML
However, browser support of XML is spotty at best
XML-related technologies
DTD (Document Type Definition) and XML Schemas are used to define legal XML tags and their attributes for particular purposes
CSS (Cascading Style Sheets) describe how to display HTML or XML in a browser
XSLT (eXtensible Stylesheet Language Transformations) and XPath are used to translate from one form of XML to another
DOM (Document Object Model), SAX (Simple API for XML, and JAXP (Java API for XML Processing) are all APIs for XML parsing
Elements and attributes
Attributes and elements are somewhat interchangeable
Example using just elements:
<name> <first>David</first> <last>Matuszek</last></name>
Example using attributes:
<name first="David" last="Matuszek"></name>
You will find that elements are easier to use in your programs--this is a good reason to prefer them
Attributes often contain metadata, such as unique IDs
Generally speaking, browsers display only elements (values enclosed by tags), not tags and attributes