The XML declaration is a processing instruction that identifies the document as being XML. All XML documents should begin with an XML declaration.
[xml]<?xml version="version_number" encoding="encoding_declaration" standalone="standalone_status" ?>[/xml]
Rules
Following are the several rules to be folloed by XML declaration.
If the XML declaration is included, it must be situated at the first position of the first line in the XML document.
If the XML declaration is included, it must contain the version number attribute.
If all of the attributes are declared in an XML declaration, they must be placed in the order shown above.
If any elements, attributes, or entities are used in the XML document that is referenced or defined in an external DTD, standalone="no" must be included.
The XML declaration must be in lower case (except for the encoding declarations).
DOCTYPE Declaration & DTDs
Description
The record sort (DOCTYPE) announcement comprises of an inner, or references an outer Document Type Definition (DTD). It can likewise have a blend of both inner and outer DTDs. The DTD characterizes the imperatives on the structure of a XML archive. It pronounces the greater part of the report's component type glossary, youngsters component sorts, and the request and number of every component sort. It likewise pronounces any characteristics, elements, documentations, handling guidelines, remarks, and PE references in the record.
The Internal DTD
[xml]
<!DOCTYPE root_element [
Document Type Definition (DTD):
elements/attributes/entities/notations/
processing instructions/comments/PE references
]>[/xml]
The following is an example.
[xml]<?xml version="1.0" standalone="yes" ?>
<!--open the DOCTYPE declaration -
the open square bracket indicates an internal DTD-->
<!DOCTYPE foo [
<!--define the internal DTD-->
<!ELEMENT foo (#PCDATA)>
<!--close the DOCTYPE declaration-->
]>
<foo>Hello World.</foo>[/xml]
The External DTD
External DTDs are valuable for making a typical DTD that can be shared between various records. Any progressions that are made to the outside DTD consequently overhauls every one of the records that reference it. There are two sorts of outside DTDs are public, private.
[xml]<!DOCTYPE root_element SYSTEM "DTD_location">[/xml]
The following is an example.
[xml]<!--inform the XML processor
that an external DTD is referenced-->
<?xml version="1.0" standalone="no" ?>
<!--define the location of the
external DTD using a relative URL address-->
<!DOCTYPE document SYSTEM "subjects.dtd">
<document>
<title>Subjects available in Mechanical Engineering.</title>
<subjectID>2.303</subjectID>
<subjectname>Fluid Mechanics</subjectname>
<prerequisite>
<subjectID>1.001</subjectID>
<subjectname>Mathematics</subjectname>
</prerequisite>
<classes>4 hours per week (lectures and tutorials) for one
semester.</classes>
<assessment>tutorial assignments and one 2hr exam at end of
course.</assessment>
<syllabus>
Fluid statics. The Bernoulli equation. Energy equation. Momentum
equation. Differential Continuity equation. Differential Energy
equation. Differential Momentum equation. Dimensional Analysis.
Similitude. Laminar flow. Turbulent flow. Lift and Drag. Boundary
layer theory.
</syllabus>
<textbooks>
<author>Foobar</author>
<booktitle>The Study of Fluid Mechanics</booktitle>
</textbooks>
</document>[/xml]
ELEMENT Type Declaration
Description
Element sort announcements set the standards for the sort and number of components that may show up in a XML report, what components may show up inside each other, and what arrange developer should show up in.
[xml]<!ELEMENT name allowable_contents>[/xml]
Summary
Key Points
Attributes are additional information associated with an element type.
NOTATIONs are useful when text needs to be interpreted in a particular way.
Enumerated attribute types allows developer to make a choice between different attribute values.