XML - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

XML Document

XML Document

shape Description

An XML document is the holder of variety of XML data which is the combination of elements and markup in an orderly package. For example, database of numbers, numbers representing molecular structure or a mathematical equation. XML Document follows all the syntactic rules of XML discussed in the previous chapter XML syntax. XML documents has three main parts. They are:
  • Prolog : XML Declaration is also called as Prolog and is optional. It indicates the version number presently in use. If the Prolog is required in the code, it must be at the top of the document. XML Declaration is case-sensitive.
  • Document Body : The content of XML document is arranged in a hierarchical structure in document body.
  • Epilog : Epilog is an optional part which is optional and contains any final comments or processing instructions.
XML Document looks similar to the HTML documents. The basic XML Document will be as follows. [xml] <?xml version="1.0"?> <contact-info> <name>Mike</name> <company>SPLessons</company> <phone>+(011) 011223366</phone> </contact-info> [/xml]
  • In the above code, XML document starts with XML Declaration <?xml ...?> which indicates that it is the XML document and the version being used. But it is not mandatory.
  • Like SGML, there will be no document type declaration in XML. If required it can be used.
  • Most of the elements in document wraps around some content.
  • XML documents are composed of markup and content.

XML Document Markup

shape Description

Document Markup are symbols or notations(<, > ^, /, ?,..) used to correct in making up text and indicate how text should be displayed. Markup is of 6 kinds. They are: All the above concepts will be discussed in detail in further chapters.

Valid Document

shape Description

Suppose there is an XML Parser and if any XML file is given to that parser and as long as the syntax is correct and elements are properly named, the file is said to be Well Formed. But, to verify everything is in a structured manner or not, a set of rules are applied to the parsing process in addition to the well-formed checks. So, if the XML parser parses the docking correctly and the document content passes the rules, then it is called Valid Document. There are two ways to check if a document is valid or not. They are:
  1. Document Type Definitions(DTDs) : Simple to use but not very powerful. These are written using a syntax that's different than XML.
  2. XML Schema Document (XSD) : This Type Definitions are more powerful than DTD and is written using XML syntax rules.
The above concepts will be discussed in detail in further chapters.

summary

shape Key Points

  • An XML document is the holder of variety of XML data which is the combination of elements and markup in an orderly package.
  • XML document starts with XML Declaration.
  • XML documents are composed of markup and content.