Tuesday 7 April 2015

XML Interview Questions And Answers

XML Interview Questions And Answers :


1.What is XML?


  • Extensible Markup Language (XML) is the universal language for data on the Web
  • XML is a technology which allows us to create our own markup language.
  • XML documents are universally accepted as a standard way of representing information in platform and language independent manner.
  • XML is universal standard for information interchange.
  • XML documents can be created in any language and can be used in any language

2.  What is a markup language? 

A markup language is a set of words and symbols for describing the identity of pieces of a document (for example ‘this is a paragraph’, ‘this is a heading’, ‘this is a list’, ‘this is the caption of this figure’, etc). Programs can use this with a style sheet to create output for screen, print, audio, video, Braille, etc. 

Some markup languages (e.g. those used in word processors) only describe appearances (‘this is italics’, ‘this is bold’), but this method can only be used for display, and is not normally re-usable for anything else.

3.What is the difference between XML and HTML?


XML is no way clashes with HTML, since they are for two different purposes.

1.HTML was designed to display data with focus on how data looks while XML was designed to be a software and hardware independent tool used to transport and store data, with focus on what data is.

2.HTML is a markup language itself while XML provides a framework for defining markup languages.

3.HTML is a presentation language while XML is neither a programming language nor a presentation language.

4.HTML is case insensitive while XML is case sensitive.

5.HTML is used for designing a web-page to be rendered on the client side while XML is used basically to transport data between the application and the database.

6.HTML has it own predefined tags while what makes XML flexible is that custom tags can be defined and the tags are invented by the author of the XML document.

7.HTML is not strict if the user does not use the closing tags but XML makes it mandatory for the user the close each tag that has been used.

8.HTML does not preserve white space while XML does.

9.HTML is about displaying data,hence static but XML is about carrying information,hence dynamic.

4. What is XPath ?


XPath is an XML technology which is used to retrieve element from XML documents. Since XML documents are structured, XPath expression can be used to locate and retrieve elements, attributes or value from XML files. XPath is similar to SQL in terms of retrieving data from XML but it has it's own syntax and rules. 

5. What is XSLT?

 XSLT is another popular XML technology to transform one XML file to other XML, HTML or any other format. XSLT is like a language which specifies its own syntax, functions and operator to transform XML documents. Usually transformation is done by XSLT Engine which reads instruction written using XSLT syntax in XML style sheets or XSL files. XSLT also makes extensive use of recursion to perform transformation. One of the popular example of using XSLT is for displaying data present in XML files as HTML pages. XSLT is also very handy to transforming one XML file into another XML document.


6.  Why is XML such an important development?

It removes two constraints which were holding back Web developments:
1. dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for;
2. the complexity of full SGML, whose syntax allows many powerful but hard-to-program options.
XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.

7.What are the benefits of XML?

There are many benefits of using XML on the Web :
  • Simplicity- Information coded in XML is easy to read and understand, plus it can be processed easily by computers.

  • Openness- XML is a W3C standard, endorsed by software industry market leaders.

  • Can embed multiple data types - XML documents can contain any possible data type - from multimedia data (image, sound, video) to active components (Java applets, ActiveX).

  • Can embed existing data - Mapping existing data structures like file systems or relational databases to XML is simple. XML supports multiple data formats and can cover all existing data structures and .

  • Contains machine-readable context information- Tags, attributes and element structure provide context information that can be used to interpret the meaning of content, opening up new possibilities for highly efficient search engines, intelligent data mining, agents, etc.

  • Separates content  from presentation- XML tags describe meaning not presentation. The motto of HTML is: "I know how it looks", whereas the motto of XML is: "I know what it means, and you tell me how it should look." The look and feel of an XML document can be controlled by XSL style sheets, allowing the look of a document to be changed without touching the content of the document. Multiple views or presentations of the same content are easily rendered.

  • Extensibility - There is no fixed set of tags. New tags can be created as they are needed.

  • Self-description- In traditional databases, data records require schemas set up by the database administrator. XML documents can be stored without such definitions, because they contain meta data in the form of tags and attributes.

  • Supports multilingual documents and Unicode-This is important for the internationalization of applications.

  • Facilitates the comparison and aggregation of data - The tree structure of XML documents allows documents to be compared and aggregated efficiently element by element.

  • Provides a 'one-server view' for distributed data - XML documents can consist of nested elements that are distributed over multiple remote servers. XML is currently the most sophisticated format for distributed data - the World Wide Web can be seen as one huge XML database.

8.  What is DOM and how does it relate to XML? 
The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily Any developer that has worked extensively with XML should be able to discuss the concept and use of DOM objects freely. Additionally, it is not unreasonable to expect advanced candidates to thoroughly understand its internal workings and be able to explain how DOM differs from an event-based interface like SAX.

9. What is SOAP and how does it relate to XML?

 The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.


10.  Why not just carry on extending HTML? 

HTML was already overburdened with dozens of interesting but incompatible inventions from different manufacturers, because it provides only one way of describing your information.

XML allows groups of people or organizations to question C.13, create their own customized markup applications for exchanging information in their domain (music, chemistry, electronics, hill-walking, finance, surfing, petroleum geology, linguistics, cooking, knitting, stellar cartography, history, engineering, rabbit-keeping, question C.19, mathematics, genealogy, etc).
HTML is now well beyond the limit of its usefulness as a way of describing information, and while it will continue to play an important role for the content it currently represents, many new applications require a more robust and flexible infrastructure.

11.What is a well-formed XML document?

If a document is syntactically correct it can be called as well-formed XML documents. A well-formed document conforms to XML's basic rules of syntax:
  • Every open tag must be closed.
  • The open tag must exactly match the closing tag: XML is case-sensitive.
  • All elements must be embedded within a single root element.
  • Child tags must be closed before parent tags.
  • A well-formed document has correct XML tag syntax, but the elements might be invalid for the specified document type.

12.What is DTD?


Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines rules for a specific type of document, including:
  • Names of elements, and how and where they can be used
  • The order of elements
  • Proper nesting and containment of elements
  • Element attributes
To apply a DTD to an XML document, you can:
  • Include the DTD's element definitions within the XML document itself.
  • Provide the DTD as a separate file, whose name you reference in the XML document.


13.What is XML Schema?



An XML Schema describes the structure of an XML instance document by defining what each element must or may contain.XML Schema is expressed in the form of a separate XML file.
  • XML Schema provides much more control on element and attribute datatypes.
  • Some datatypes are predefined and new ones can be created.

  • <xsd:schema  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element  name="test">
           <xsd:complexType>

14.What is a Complex Element?


A complex element is an XML element that contains other elements and/or attributes.
There are four kinds of complex elements:
  • empty elements
  • elements that contain only other elements
  • elements that contain only text
  • elements that contain both other elements and text


15.What is a Simple Element?



A simple element is an XML element that can contain only text.
  • A simple element cannot have attributes
  • A simple element cannot contain other elements
  • A simple element cannot be empty
  • However, the text can be of many different types, and may have various restrictions applied to it

16.  What is an XML namespace? 

An XML namespace is a collection of element type and attribute names. The collection itself is unimportant -- in fact, a reasonable argument can be made that XML namespaces don't actually exist as physical or conceptual entities . What is important is the name of the XML namespace, which is a URI. This allows XML namespaces to provide a two-part naming system for element types and attributes. The first part of the name is the URI used to identify the XML namespace -- the namespace name. The second part is the element type or attribute name itself -- the local part, also known as the local name. Together, they form the universal name. 

This two-part naming system is the only thing defined by the XML namespaces recommendation

17.What are the ways to use namespaces?


There are two ways to use namespaces:
  • Declare a default namespace
  • Associate a prefix with a namespace, then use the prefix in the XML to refer to the namespace

18. Does XML replace HTML? 

No. XML itself does not replace HTML. Instead, it provides an alternative which allows you to define your own set of markup elements. HTML is expected to remain in common use for some time to come, and the current version of HTML is in XML syntax. XML is designed to make the writing of DTDs much simpler than with full SGML. (See the question on DTDs for what one is and why you might want one.



No comments:

Post a Comment