XML Prolog
- Categories Uncategorized
Here we are going to cover XML Prolog. You can watch our video on XML Prolog – click here.
Q. What is the logical structure of an XML –document?
Ans: XML -document consists of mainly
The Prolog
The Data Instance
Q. What is Prolog?
Ans: Prolog is an optional structure element, but for well formed document, it must be included It has five components.
- XML Declaration
- Processing instructions
- Document type Declaration
- Comments
- White Space
Q. What are the components of Prolog?
Ans: The prolong has five components
- XML Declaration
- Processing instructions
- Document type Declaration
- Comments
- White Space
Q. What is XML Declaration?
Ans: XML Declaration: XML Declaration contains details to prepare an XML processor to parse the XML document
It provides below information.
- XML version used
- character encoding used
- Whether it has external Document Type definition or not.
E.g. A complete Xml declaration will look like:
< ? xml version = “1.0” encoding = “UTF-8” standalone = “no” ? >
The XML version is by default 1.0.
Encoding gives the character encoding used in the document. Unicode UTF-8 is the default value however most XML processors support UTF-16, Windows-1252, and ISO-8859 too.
Standalone has default value of no. It is set to yes if you have an external DTF file.
Q. What are the rules for XML declaration?
Ans: If you include XML declaration it needs to follow below rules.
- It has to be first line in the document and mandatorily need to have version number.
- All attributes need to be in the given order.
- Attribute Names have to be in lower case
- Values need to be in single or double quotes.
- Note that declaration has no closing tag i.e. < /?xml >
Q. What is Processing instructions or PI?
Ans: Processing instruction or PI are the instructions that pass information to applications. A processing instruction has the following syntax.
< ? Appname attributes >
Its typically used to link style sheets as shown below.
e.g. <? Xml -stylesheet type = “text /css” href = “main.css”?>
- It can occur anywhere in the document
- Programs which do not recognize it can ignore it.
Q. What is Document type Declaration?
Ans: The document type declaration consists of Markup codes (i.e. tag etc.) that indicate the grammar rules for the particular class of the document. The grammar rules are called Document Type Definition (DTD).
It gives information on the
- Name of the root element
- Specifies the DTD which the document uses. It can be internal meaning embedded in DOCTYPE declaration or external.
- Here’s a syntax and example.
< ! DOCTYPE myinfo >
< ! DOCTYPE myinfo SYSTEM= ”myinfo.dtd” >
Q. What are Comments in prolog?
Ans: The comments are not processed by XML -parsers .The comments are inserted for purpose like:
a . To add notes about document structure
b . To break a document into sections
E.g. <!— Almost finishing Prolog –>
Q. What is White Space is Prolog?
Ans: White space refers to spaces, tabs, carriage-return and blank lines. You can insert whitespaces to enhance readability of your document. XML parsers ignore additional white spaces
Q. What are the set rules for XML body?
Ans: There are few set rules for the body.
- XML document must contain one element that is parent of all other elements This parent element is known as root element or document element.
Lets add our root element. We already have decided on the name. - Tags in XML are case sensitive.
- XML, document must contain at least one element .
- All elements must be nested properly i.e. ,the start and end tags of child element cannot overlap.
- XML document must contain one element that is parent of all other elements This parent element is known as root element or document element.