XML
(eXtensible Markup
Language)
Introduction to XML
1.
XML
is designed to describe data, and to focus on what data it is.
2.
HTML
is designed to display data, and to focus on how data looks.
3.
In
XML the user can create their own tags, but in HTML it cannot be done.
4.
XML
are like HTML tags.
5.
XML
tags are not predefined tags own tags must be defined.
6.
XML
use a DTD (Document Type Definition) to describe the data.
7.
XML
is designed to carry data.
8.
HTML
is about displaying information XML is about describing information.
9.
XML
file name has .xml as extension.
10.
XML
coding is written in Notepad.
11.
XML
is executed in Browser like Netscape Navigator and Microsoft Internet Explorer.
12.
The
WML (Wireless Markup Language) is used to markup Internet applications for
handle devices like mobile phones, is written in XML.
13.
The
Syntax rules of XML are very simple and very strict.
14.
XML
statements are strictly case sensitive.
15.
Every
XML program must have XML Declaration statement.
XML Declaration Statement
Syntax:
This statement is to declare the XML
document. It must be written on the first line.
VERSION=“1.0” à Specifies the version of
the XML standard that the XML document conforms to.
STANDALONE à Use of YES if the XML
document has an internal DTD. Use of NO it the XML document is linked to an
external DTD.
Declaration Rules
1.
XML
statement must be first line.
2.
It
must be contain version name attribute.
3.
Attribute
values must be in double quotes.
4.
The
order of the syntax should not be changed.
5.
If
any elements, attributes or entities are used in the XML document that are
referenced or defined in an external DTD STANDALONE=”NO” must be included.
6.
It
must be in lower case except for the encoding declarations.
7.
No
close tag for XML declaration statement.
XML Program Structure
Root Element
This is the first element in a
document. It may not be contained by any other element in the document, hence,
forms the basis of the document’s element tree.
Parent Element
An element in which another child
element is nested.
Child Element
An element nested inside another
parent element.
DTD (Document Type Definition)
A set of rules describing the
structure of an XML document. There are two types of DTD.
1.
Internal
DTD
2.
External
DTD
Internal DTD
Syntax:
[
document type definitions(DTD):
elements
/ attributes / entities / notations / processing instruction /
comments
/ PE reference
]>
An internal DTD that is located within
the XML document.
Rules
1.
DTD
must be placed between the XML declaration and the root element in the document.
2.
The
keyword DOCTYPE must be followed b the name of the root element in the XML
document.
3.
The
keyword DOCTYPE must be in upper case.
External DTD
Syntax:
[SYSTEM “DTD Location”>
A DTD that is contained in another
file, which may reside at a remote location. External DTDs are useful for
creating a common DTD that can be shared between multiple documents. Any
changes that are made to the external DTD automatically update all the
documents that reference it. There are two types of External DTD’s.
1)
Private
2)
Public
Rules
If any elements, attributes or
entities are used in the XML document that are referenced or defined in an
external DTD, standalone=“no” must be included in the XML declaration.
Element Declaration
Syntax:
These declarations are placed inside a
DTD. They specify what elements are allowed in an XML document and what their
content ma be.
Rules
1.
The
ELEMENT must be in uppercase.
2.
Start
with “<” and end with “>”.
3.
An
element type cannot be declared more than once.
4.
Allowable
contents are “EMPTY”, “ANY”, child elements and mixed contents.
Attribute Listing Declaration
Syntax:
attribute type
default value>
Attributes are additional information
associated with an element type. The ATTLIST declarations identity, which
element types may have attributes, what types of attributes they may be and
what the default values of attributes are.
Entity Type Declaration
Syntax:
Entity declarations are placed inside
a DTD. They contain the abbreviation to be used for an entity and the text to
be substitute for that abbreviation. They may also contain a URI if the text or
data is stored at a remote location.
CDATA
Syntax:
#CDATA
Character data or text that does not
need to be parsed. Markup within CDATA sections will not be interpreted as markup.
PCDATA
Syntax:
#PCDATA
Parsed character data. Text that is
not markup that is processed b a parser.
Parser
An application that processes a
document and identifies text from markup. It interprets the markup and
determines the content and characteristics of a document.
Document Model
The XMLDOM (Document Object Model) is
a programming interface for XML documents. It defines the way an XML document
can be accessed and manipulated programming language and any operating system.
With the XMLDOM, a programmer can
create and XML document, navigate its structure and modify, add or delete its
elements.
Element Declaration Symbols
It is used to establish content model
of elements.
Sno
|
Symbols
|
Descriptions
|
1.
|
,
|
Separates the items in a sequence
and establishes the order in which they must appear.
|
2.
|
|
|
Separates the items in a choice
group of alternatives.
|
3.
|
No symbol
|
Indicates that a child element must
appear exactly once.
|
4.
|
?
|
Indicates that a child element must
appear exactly once or not at all.
|
5.
|
*
|
Indicates that a child element can
appear any number of items.
|
6.
|
+
|
Indicates that a child element can
appear at least once.
|
7.
|
()
|
Enclose a sequence or choice of
alternatives.
|
Programs
File name 3(a): Ext1.xml
File name 3(b): Ext1.dtd
File name 3(c): Ext1.html
XML called in HTML
File name 4(a): Prod.xml
File name 4(b): Prod.dtd
File name 4(c): Prod.html
XML called in HTML
No comments:
Post a Comment