Saturday, January 22, 2011

XML - Introduction


XML Basics

  • XML stands for eXtensible Markup Language.
  • XML is designed to transport and store data.

  • What is XML?
  1. XML stands for EXtensible Markup Language
  2. XML is a markup language much like HTML
  3. XML was designed to carry data, not to display data
  4. XML tags are not predefined. You must define your own tags
  5. XML is designed to be self-descriptive
  6. XML is a W3C Recommendation
  • The Difference Between XML and HTML :
  1. XML is not a replacement for HTML.
  2. XML and HTML were designed with different goals:
  3. XML was designed to transport and store data, with focus on what data is.
  4. HTML was designed to display data, with focus on how data looks.
  5. HTML is about displaying information, while XML is about carrying information

  • Understanding the Vocabulary:
Well-formed XML:


  • Rules of Elements:
  1. Element names cannot contain white space
  2. Names cannot start with a number or a punctuation mark
  3. Names cannot start with xml or variants
  4. No space after the left angle bracket (<)
  5. The case of start and closing tags must match
  6. The first element is the root element
  7. The root element must have start and closing tags
  8. All child elements must nest within the root
  9. Nesting elements cannot overlap
  10. An empty child element can consist of a single tag

  • Rules of Attributes:
  1. Declare them in start tags and processing instructions
  2. Separate multiple declarations with a space
  3. An attribute consists of a name and an assignment
  4. Each name must be unique within an element
  5. You can reuse names throughout a document
  6. There are no spaces in names
  7. Use either single or double quotes for assignments
  8. <Book Type="IT">XML Principles</Book>

  • Processing instructions to applications
  • Use it to send a command to an external application
  • Multiple PIs to applications are allowed
  • <?MyDbAppSELECT * FROM orders?>

  • Processing instructions to the XML processor –  the XML declaration
  1. It begins with the XML keyword
  2. It must appear only once per document at the top of the document
  3. Use it to declare the XML version and character encoding
  4. <?xml version="1.0" encoding="UTF-8"?>


  • Comments:
  • Do not embed a comment within a tag
  • <Books><!--IT--></Books>         Error: <Books<!--IT-->></Books>
  • Use the double hyphen (--) only to open and close the comment
  • <--Option use–fas option -->      Error:<--option use  --d as option-->
  • Do not use a triple hyphen (---) at the end
  • <---10 Centigrade -->     Error: <---10 Centigrade --->

  • Reserved Characters:


                     Reserved Characters
Entity References
&
&amp;
&lt;
&gt;
'
&apos;
"
&quot;
Space
&nbsp;

  • What Is an XML Vocabulary?
  • Problem: two XML sources cannot be easily combined
  • Solution: each XML source shares the same structure, naming, and case
  • Guidelines for Creating Vocabularies
  1. Determine if a vocabulary already exists
  2. Make your XML easy to read and understand
  3. Use title case for elements and attribute names
  4. Avoid abbreviations

No comments:

Post a Comment