XML Question
XML Question
Disadvantages
The event-driven model of SAX is useful for XML parsing, but it does have certain
Certain kinds of XML validatlon requires accessto the document in full. For example, a DTO
drawbacks
IDREF attribute requires that there be an element in the document that uses the given string as a
DTD ID attribute. To validate this in a SAX parser, one would need to keep track of
encountered ID attribute and every previously encountered IDREF attribute, seeevery if anypreviousy
matches
are made. Furthermore, an IDREF does not match an ID, the user only discovers this ater he
document has been parsed; if this linkage was important to building functioning output, then ime hat
been wasted in processing the entire document only to throw it away.
Additionally,some kindsof XML processing simply require having access to the entire document
XSLT and XPath, for example, need to be able to access any node at any time in the parsad
XML tree. While a SAX parser could be used to construct such a tree, the DOM already does so by
design.
SUMMARY
1. XML 0s a way of marking up data, adding metadata and separating structure from formatting and stvle
document.
2. With XML youcan store information about your documents and pieces of your
3. XML is really nothing more than a specification.
language.
4. XML naming rules are same as any other variable names in other programming
<empty.element>.
5 Empty elements have no content and are marked up as
appear at least once and may
6. The + character indicates that an element or group of elements must
appear one or more times.
XML document.
7. DTD describes a model of structure of the content of an
content model of a type of documents.
8. The document type definition is an XML description of the
file that identifies the DTD that belongs tothe
9. The document type declaration is astatement in an XML
document.
element
source object andDATAFLD specifies the data to which
10. DATASRC refers to the name of the data
is bound.
GLOSSARY
included inside a
An XML structural construct. A name-value pair, separated by an equals sign,
Attribute: includingthings like size
of the element. All attribute values,
tagged element that modifies certain features in quotation
numbers. For XML, all values must be enclosed
and width, are in fact text strings and not
marks.
Youcan declare attributes for an XML
element type usingan attribute list declaration.
descriptions that provide augmented control over presentation
Cascading Style Sheets (CSS) :FormattingCSS can be used for describing the formatting behavior of simply
and layout of HTML and XML elements. from the structure of tne
XML documents, but does not provide a display structure that deviates
structured
Language.
source data. See also Extensible Stylesheet Internet Explorer 4.0and
Definition Format (CDF): An XML-based data format used in Microsoft®
Çhannel
content and desktop components.
later to describe Active Channel T"
120 INTRODUCTION TO WEB
XML parser : Asoftware module used to read XML documents and provide access to
structure. The XML parser generates a hierarchically structured tree, then hands off
other applications for processing. and finally returns the results to the browser.
also checks the XML syntax and reports errors.
A
TvalidatiEnCgHNviOeLwer0Gs
datatheitor content
XML parse
SHORT QUESTIONS WITH ANSWERS
Q.1. What is XML?
Ans. XML is the Extensible Markup Language. It improves the functionality of the Web by
becauseleting you
identify your information in a more accurate., flexible and adaptable way. It is extensible
a fixed format like HTML
(which is a single, predefined markup language). Instead, XML itis no
meta language- alanguage for describing other languages-which lets you design your own markuois actualy
for limitless different types of
Q.2. What is a markup language?
documents. language
Ans. Amarkup language is a set of words and symbols for describing the identity ot pieces of a docurme.
(ror example this is aparagraph, this is a heading'. "this is a list, this is the caption of this figure' e
Programs can use this with a style sheet to create output for screen, print, audio, video, Braille tr
Q.3. Where should Iuse XML?
Ans. Its goal is to enable geñeric SGML to be served, receivedand processed on the web in the way th
is now possible with HTML. XML has been designed for ease of implementation and for interoperabi
with both SGML and HTML.
Despite early attempts, browsers never allowed other SGML, only HTML (although there were plugins
and they allowed it (even encouraged it)to be corrupted or broken, which held development back for ov=
adecade by makingit impossible to program for it reliably. XML fixes that by making it compulsory to stic
to the rules, and by making the rules much simpler than SGML.
Q.4. Why is XML such an important development?
Ans. It removes two constraints which were holding back Web developments:
1. dependence on a single, inflexible document type (HTML) which was being much abused f
tasks it was never designed for;
2. the complexity of full SGML, whose syntax allows many powerful but
XML allows the flexible development of user-defined document types. It provideshard-to-program option
a robust, non-proprieta:
persistent and verifiable file format for the storage and transmission of text and data both on and off th
Web; and it removes the more complex options of SGML, making it easier to program for.
Q.5. Describe the differences between XML and HTML.
(UPTU 200
Ans. It's amazing how many developers claim to be proficient programming with XML, yet do not
the basicdifferences between XML and HTML. Anyone with a fundamental grasp of XML understar
should be at
to describe some of the main differences outlined in the table below.
XML User definable tags
Content driven
End tags required for well formed documents
Quotes required around attributes values
Slash required in empty tags
HTML Defined set of tags designed for web display
Format driven
End tags not required
Quotes not required
Slash not required.
AL(EXTENSIBLEMARKUPLANGUAGE) 121
responsible for XML?
Whois
a.6.
XMLisa
projectoof the World Wide Web Consortium(W3C), andthe development of the specification
supervisedbyan
Ans. XML Working Group. ASpecial Interest Group of co-opted contributors and experts
fields contributed comments and reviews by e-mail.
is various
from
membership
public format: it is not a proprietary development of any cormpany. although the
XMLisa acadermic institutions. The v1.0
WG and the SIG represented companies as well as research and
ofthe was accepted by the W3Cas a Recommendation on Feb 10, 1998.
specification
V. Imp)
WhyisXML such an important development?
Q.7.
removes two constraints which were holding back Web developments:
Ans. It was being much abused for
dependence on a single, inflexible document type (HTML)which
tasks it was never designed for:
syntax allows many powerful but hard-to
the complexity of full question A.4, SGML, whose
program options.
document types. It provides a robust, non-proprietary.
VMI allows the flexible development of user-defined data both on and off the
for the storage and transmission of text and
persistent, and verifiable file format
SGML, making it easier to program for.
ah: and it removes the more complex options of
DTDs or schemas that you have
worked with.
a8 Give some examples of XML the benefits of using
Although XML does not require data to be validated against aDTD, many of technical
Ans.
derived from being able to validate XML documents against business or
the technology are to their
Polling for the list of DTDs that developers have worked with provides insight commonly
architecture rules. knowledge of several of the
exposure to the technology. The ideal candidate will have custom DTD for
general
FpML, DocBook, HRML, and RDF, as wellas experience designing a
used DTDs such as
no standard existed.
a particular project where external entity reference in an
attribute
DTD, how do you create an
Q.9. When constructing an XML
using
value?
have at least one trick question. Although possible when
should important
Ans. Every interview session defining external entity references in attribute values. It's moresomewhat
SGML, XML DTDs don't support candidate know the
respond to this question in a logical way than the
for the candidate to
obscure answer.
of XML data?
would youbuild asearch engine for large volumes XML data. For those
Q.10. How provide insight into their view of
answer this question may files, a common answer is to
builda full-text
Ans. The way candidates structure for text
who view XML primarily as
a way to denote
Internet portals handle HTML pages. Others consider
similarly to the way These candidates
search and handle the datatransferring structured data between desparate systems. relying on the
XML as a standard way of importing XML into a relational or object database and
of
often describe some scheme
database's engine for searching.
(V. Imp)
HTML? allows you to define
Q.11. Does XML replace HTML. Instead, it provides an
alternative which
come.
not replace some time to
Ans. No. XML itself does HTML is expected to remain in Common use for DTDs much
elements. of
your own set of markup syntax. XML is designed to make the writing
HTML 0s in XML
and the Currentversion of
SGML.
simpler than with full Iget one? (UPTU 2006)
Document Type Definition (DTD) and where do document. It sets
Q.12.What's a Declaration Syntax of a particular type or class of
in XML they all
Ans. A DTD is a description different types of element, where they may occur, and how more
for the allows
outwhat names are to be usedSchema does the same thing in XML Document Syntax and
together. (A question C.16,
fit
extensive data-checking.) the
document type to be able to describe Lists which contain ltems.
Eor example, if you want a like this:
might contain something
relevant part of your DTD
122
INTRODUCTION TO WEB
<!ELEMENT List (Item)+>
<!ELEMENT Item (#PCDATA)>
This defines a list as an element type containing one or more items (that's the
defines items as element types containing just plain text (Parsed Character Data
or
TplusECsiHNgOn\L,OGand
PCDATA).
read the DTD before they read your document so that they can identity where every element Va
to come and hoW each relates to the
other. so that applications which need to
editors, search engines, navigators, and databases) can set
knowthis in advance
themselves correctly. The
up Malidalors
type (most
oughN
lets youcreate lists like:
<List>
example abOVe
<Item> Chocolate</Item>
<Item> Music</Item>
<Item>Surfingv</Item>
</List>
EXERCISES