Pages

November 01, 2016

XML interview questions and answers

What is a markup language?Markup languages are designed for presentation of text in different formats, and it can also be used for transporting and storing data. This markup language specifies the code for formatting, layout and style of data .This markup code is called Tag.



What is XML?
    • XML(eXtensible Markup Language) is a simple and flexible markup language. It is known as universal language for data on the web because XML documents can be created and used in any language. It is universal standard for information interchange.
    • XML is platform and language independent, XML documents can be created in any language and can be used in any language.
    • XML technology facilitates you to create your own markup language.
    How XML is different from HTML?
    • HTML is used to display data and focuses on how data looks. Where as, XML is a software and hardware independent tool used to transport and store data. It focuses on what data is.
    • HTML is a markup language itself. XML provides a framework to define markup languages.
    • HTML is not case sensitive. XML is case sensitive.
    • HTML is a presentation language. XML is neither a presentation language nor a programming language.

    What are the benefits of XML?
    • Information coded in XML is easy to read and understand, plus it can be processed easily by computers.
    • XML files are text files, and no editor is required.
    • There is no fixed set of tags. New tags can be created as they are needed.
    • 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.
    • 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.
    • 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.
    • 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 .
    • 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.
    What is a well-formed XML document?
    If a document is syntactically correct it can be called as well-formed XML documents. In a well-formed document :
    • 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.
    What is a valid XML document?
    If a document is structurally correct then it can be called as valid XML documents. XML document is implicitly well-formed, but well-formed may not be valid. A valid document conforms to the predefined rules of a specific type of document:
    • These rules can be written by the author of the XML document or by someone else.
    • The rules determine the type of data that each part of a document can contain.
    How does the XML structure is defined?
    XML document will have a structure which has to be defined before we can create the documents and work with them. The structural rules can be defined using many available technologies, but the following are popular way of doing so-
    • Document Type Definition (DTD)
    • Schema
    What is DTD?
    A 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.
    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 >


    What is XML DOM?
    DOM stands for Document Object Model which is used to describe the logical structure of XML document. It is a hierarchical model that provides a way to access and manipulate an XML document. DOM methods and objects can be used with any languages like C#, VB, JavaScript and VB Script.

    What is SAX in XML?

    SAX stands for Simple API for XML. It is a sequential access parser. It is a simple API for XML which provides a mechanism for reading data from an XML document. It is an alternative of DOM. DOM operates on the documents as whole, SAX parsers operate on each piece of the XML document sequentially.

    SAX has no formal specification like DOM and consumes less memory. But it can be used to read the XML document only not write.

    What is XSL?
    XSL is a language used with XML for expressing style sheets as like CSS. It describes how to display an XML document for a given type.

    What are the three parts of XSL?

    XSLT – Used to transform XML documents
    XPath – Used for navigating in XML documents
    XSL-FO – Used for formatting XML documents

    What is XSLT?
    XSLT is a popular XML technology which is used to transform one XML file to other format like HTML etc. XSLT is like a language which has its own syntax, functions and operator to transform XML documents. XSLT is also used to display data present in XML files as HTML pages.

    What is XPath in XML?
    XPath is a technology used in XML. It is used to retrieve elements from XML documents. XPath expressions can be used to locate and retrieve elements, attributes and values from XML files because XML documents are structured. It is similar to SQL.

    As SQL is used to retrieve data from database, XPath is used to retrieve data from XML. 
       
    What is XQuery?
    XQuery was designed to query XML data which is nothing but SQL for database tables. XQuery is used to fetch the data from the XML file.

    -K Himaanshu Shuklaa..

    No comments:

    Post a Comment