The various building blocks of an XML document is shown in the document
below
The Prolog consisits of two internal blocks .
The first block defines the XML version declaration
which is optional.
<?xml version = "1.0" ?>
DTD(document type definition)
Prolog
Version
Declaration
DTD
<root>
.......body
<root>
Parts of an XML Document
For any existing XML document, the XML specifications defines
a set of rules using a DTD to which the XML document conforms.A DTD can
either be an external or an internal file.A DTD can be declared internally
within the document type declaration
(example: lets consider the DTD for personal information)
< ! DOCTYPE name [
....<!ELEMENT name (first_name+, .........................middle_initial+,
last_name+)>
....<!ELEMENT first_name (#pcdata)>
....<!ELEMENT middle_initial (#pcdata)>
....<!ELEMENT last_name (#pcdata)>
]>
If the DTD is an external file we link to the document in
the following way.
<!DOCTYPE name SYSTEM "name.dtd"
>
Well formed and Valid Documents
The XML specifications defines 2 types of documents. Well formed Valid documents.
A Well formed document must confirm
to the following rules.
The document
must contain atlest one element. The document
must contain a root element which is unique and surrounds the whole document. All other elements
must be within the root element with no overlapping. There should
be no unclosed tags.Every start tag must have an end tag.
Lets take the example of personal information once again.the following
is a well defined document for that
Valid documents on the other hand should not only be well
formed but also have a DTD to which the well formed documents conforms
to.This means that it must only use the elements which have been declared
in the DTD.
Extensible Style Sheets(XSL)
XSL is used for the display of an XML document.
An XSL document consists of a number of template rules that have 2 parts.
A Pattern part An Action part
The pattern part selects an object from the source
document .
The action part of the rule describes what styling
is to be applied to it. XSL takes more complex stylesheet and simplifies
it.It also supports CSS.
XSL helps to display information in a number of different ways without
going back to the server.
XML Parser
A parser is a piece of software that makes sure the XML document is valid
or at least well-formed. Parsers are extremely complex to develop and
so only experienced programmers will design one. Once a parser is developed,
other programmers and Web designers can easily reuse it .A parser is part
of XML that you will never see.