XML(Extensible Markup Language)

1) What is a markup language?

Ans) 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. HTML and XML are examples of Markup Language.


2) What is XML?

Ans) XML is called Extensible Markup Language which is designed to carry or transport and store data. XML tags are not as predefined as HTML, but we can define our own user tags for simplicity. It mainly concentrates on storing of data, not on displaying of data.


3) What are the features of XML?

Main features of XML are: • Very easy to learn and implement • XML files are text files, and no editor is required • Minimal and a limited number of syntax rules in XML • It is extensible, and it specifies that structural rules of tags

4) What is a StAX Parser?

Ans)StAX is a JAVA based API to parse XML document in a similar way as SAX parser does but StAX is a PULL API where as SAX is a PUSH API. It means in case of StAX parser, client application need to ask StAX parser to get information from XML whenever it needs but in case of SAX parser, client application is required to get information when SAX parser notifies the client application that information is available. </p> <br/> <p><b>5) What is XML DOM Document?</b></p> <p>Ans) XML Document object represents the whole XML document, and it is the root of a document tree. It gives access to entire XML document – Nodes and Elements, and it has its own properties. </p> <br/> <p><b>6) What is XPath?</b></p> <xmp> XPath is used to find information in an XML document and contains standard functions. XPath is the major element in XSLT, and it is w3c recommendation.


7) What is an attribute?

Ans) An attribute provides more or additional information about an element than otherwise. Example – <Person name=”Peter”> <Person name=”Peter”> Attribute name can be given to an element person.


8) Can we have empty XML tags?

Ans) Yes, we can have empty tags in XML. Empty tags are used to indicate elements that have no textual content. Empty tags can be represented as <person></person> <person/> <person></person> <person/>


9)What are the advantages of XML DOM Document?

Ans)Advantages of XML DOM:

  • XML structure is traversable, and it can be randomly accessed by traversing the tree.
  • XML structure is modifiable, and values can be added, changed and removed

  • 10)What are the basic rules while writing XML?

    Ans) These are the basic rules while writing XML:

  • All XML should have a root element
  • All tags should be closed
  • XML tags are case sensitive
  • All tags should be nested properly
  • Tag names cannot contain spaces
  • Attribute value should appear within quotes
  • White space is preserved

  • 11) What is XML Element?

    Ans) An XML document contains XML Elements, and it starts from an element’s start tag to end tag. It can contain:

  • Other elements within main element
  • An Attribute
  • text

  • 12) What is CDATA?

    CDATA is unparsed character data that cannot be parsed by the XML parser. Character < and > are illegal in XML elements. CDATA section starts with <![CDATA[“ and end with “]]>”.

    13) How comment can be represented in XML?

    Comment can be represented as <!- – comments – -> as like HTML. This comment symbol is applicable for single or multiple lines.


    14) What are XML Namespaces?

    Ans) XML namespaces are used to avoid element name conflicts, and it can be avoided by using prefix before the name.


    15) What is XML Parser?

    Ans) XML Parser is used to convert from XML document into an XML DOM object which can be written in Javascript.</p>

    16) What is XSL?

    Ans) 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.


    17) Who is responsible for XML?

    Ans) XML is a recommendation of the W3C – World Wide Web Consortium and the development are supervised by XML working group.


    18) What is an XML Schema?

    Ans) Yes, older HTML files are compliant to the HTML standard. Most older files work on the newer browsers, though some features may not work.


    19) Does a hyperlink apply to text only?

    Ans)An XML schema gives the definition of an XML document, and it has following: • Elements and attributes • Elements that are child elements • Order of child elements • Data types of elements and attributes

    20) What is well formed XML document?

    Ans) A well-formed XML document must follow the following rules –

  • Every start tag should end with an end tag
  • XML tags are case sensitive
  • Empty tags are necessary to close with a forward slash
  • All tags should be properly nested

  • 21) Why XML has been used for development?

    Ans) XML is used for development for following reasons: • Used for Database driven websites • Used to store data for e-commerce websites • Used to transport and store data on internet • XML is used for database and flat files • Generate dynamic content by applying different style sheets


    22)What is SGML?

    Ans) SGML is large and powerful Standard Generalized markup Language which is used to define descriptions of the structure of different types of electronic document.


    23) Can I execute a XML?

    Ans) No, we cannot execute XML, and it is not a programming language to execute. It is just a markup language to represent the data.

    24) What are the special characters used in XML?

    Ans) <, > and & are the special characters used in XML. Because these characters are used for making tags.


    25) What software is available for XML?

    Ans) There are thousands of programs available for XML and updated list will be present in http://xml.coverpages.org.


    26) Can I replace HTML with XML?

    Ans) No, XML is not a replacement of HTML. XML provides an alternative approach to define own set of markup elements, and it is used for processing and storing data.


    27)How can I include conditional statements in XML?

    Ans) We cannot include conditional statement as like programming language. <foo if{DB}="A">bar</foo> <foo if{DB}="A">bar</foo> This can be done by using Document Type Definition(DTD). <xsl:if test="@foo=’bar’"> <xsl:text>Hello, world!</xsl:text> </xsl:if> <xsl:if test="@foo=’bar’"> <xsl:text>Hello, world!</xsl:text> </xsl:if>


    28) What are the benefits of XML?

    Ans) Benefits of XML are

  • Simple to read and understand
  • XML can be done with a text editor
  • Extensibility – No fixed tags
  • Self – descriptive
  • Can embed multiple data types.

  • 29) What are the disadvantages of XML?

    Ans)Following are the disadvantages of XML:

  • XML will be just a text file if elements and attributes are not defined properly.
  • Overlapping markup is not permitted

  • 30) What is DTD?

    Ans) DTD is abbreviated as Document Type Definition and it is defined to build legal building blocks of an XML document. It defines the XML document structure with elements and attributes.


    31)Why XSLT is important for XML?

    Ans) XSLT is abbreviated as eXtensible Sytlesheet Language Transformation which is used to transform an XML document to HTML before it is displayed to the browser.


    32) What are nested elements in XML?

    Ans) If one or more elements are nested inside the root element is called nested element. Nesting can be easy to understand and also keeps order in an XML document.

    33) What is XQuery?

    Ans) 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.


    34) What is the meaning of version in XML?

    Ans) Version is a tag used to show which version of XML is used.

    35) What is XML DOM?

    Ans) 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.


    36) What is SAX in XML?

    Ans)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.

    37) What is XSNL?

    Ans) XSNL is an XML search neutral language. This language acts between the meta search interface and targeted system.

    38) What is DTD?

    Ans)DTD stands for Document Type Definition. It defines a leading building block of an XML document. It defines: 1.Names of elements 2.How and where they can be used 3.Element attributes 4.Proper nesting

    39) How can you apply a DTD to an XML document?

    Ans)To apply a DTD to an XML document, you can: 1.Use the DTD element definition within the XML document itself. 2.Provide a DTD as a separate file and reference its name in XML document.

    40)What is XPath in XML?

    Ans) 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.

    41) What is XSLT?

    Ans) 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.


    42) Define the concept of XPOINTER.

    Ans) XPOINTER is used to point data within XML document. It is used to locate the particular part of the XML document. It is a W3C recommendation.


    43) What is XML data binding? Why is it used?

    Ans) XML data binding is the process of representing the information in an XML document as an object in computer memory. XML data binding is used to short your development effort, simplify maintenance, increase reliability. It saves your development time and money. It makes working with XML data very intuitive.


    44) What is XML encoding error?

    Ans) There are two types of XML encoding errors:

  • An invalid character was found in text content.
  • Switching from current encoding to specified encoding not supported.
  • These errors occur because XML document can contain non ASCII characters like Norwegian and French. These errors can be avoided by specifying the XML encoding Unicode.

  • 45) What are the different XML API's?

    Ans) API'Sare

  • Tree-based API: It compiles an XML document in a tree like structure and loads it into the memory. You can traverse and change the tree structure. Tree based API's are useful for a wide range of applications. Example of tree-based API is DOM parser.
  • Event-based API: An event based API provides the reports to an application about the parsing event. It uses a set of built-in call back functions. Example of event-based API is SAX parser.

  • 46)What is XmlReader class? Explain.

    Ans) The XmlrReader class represents a reader that provides fast, noncached, forward-only access to XML data. You need to import the following namespaces to work with XmlReader class in .NET. In VB: Imports System.Xml In C#: using System.Xml;


    47) What is the difference between CDATA and PCDATA?

    Ans) CDATA means unparsed character data whereas PCDATA means parsed character data.


    48)What is XML Namespace?

    Ans) A namespace is a qualified name that is associated with the DTD/Schema location . A document may have duplicate elements and attributes. So, the namespace defines a way to compare duplicate elements and attribute names.


    49) What is SGML?

    Ans) SGML is a vast and powerful generalized markup language that is used to define descriptions for the structure of several electronic documents.


    50) Can we use graphics in XML?

    Ans) Yes, graphics can be stored in XML file by using XLink and XPointer. It supports graphics like GIF, JPG, TIFF, PNG, CGM, EPS, SVG.


    51) Is XML case sensitive?

    Ans) Yes, XML is a case sensitive language.


    52) What is the difference between simple element and complex element?

    Ans) In XML, simple elements are text-based elements. It contains less attributes, child elements, and cannot be left empty. But, complex elements can hold multiple attributes and elements. It can contain additional sub elements and empty element also.


    53) Why XML editor is needed instead of Notepad?

    Ans) XML editors are required to write error free XML documents, and it is used to validate against DTD or schema. Editors are able to check:

  • Open and Close Tags
  • XML against DTD
  • XML against Schema
  • Color code on XML Syntax

  • 54) What is XML Encoding?

    Ans) 1. XML documents may contain Non-ASCII characters like French and Norwegian characters. 2.XML Encoding is used to avoid errors and XML files have to be saved as Unicode.


    55) What is Simple Element?

    Ans) A simple element contain only text and following are the kinds of Simple Element: 1.No attributes 2.Doesn’t contain other elements 3.It cannot be empty


    56) Is there a way to describe XML data?

    Ans)Yes, XML uses Document Type Definition (DTD) to describe the data.


    57) What are the three parts of XSL?

    Ans) XSL consists of three parts:

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

  • 58) What is the correct syntax when we define XML version?

    Ans)


    59) If XML attribute name itself has double quotes, then how it can be represented?

    Ans) Attribute name can be represented within single quotes if double quotes are present in the attribute name. <country city='Texas "US"'></country> <country city='Texas "US"'></country>

    60) What are the types of XML Parsers?

    Ans)There are two types of parsers – Non-Validating and Validating Parsers. Name itself implies Non-Validating will not validate the XML and Validating parser will validate the XML with DTD.


    61) Whether root element is required for XML? If so, how many root elements are required?

    Ans) Yes, root element is required, and it can have only one root element in each XML.


    62) What is XML Signature?

    Ans) XML Signature is recommended by W3C, and it acts as a digital signature for XML documents. If the signature is contained outside the document, it is called detached signature. If it contains inside the XML document, then it is called Enveloping signature.


    63) What is Data Island?

    Ans) An XML Data island is XML data embedded into a HTML page. This works only with the Internet.


    64)What is DiffGram in XML?

    Ans) A DiffGram is an XML format which is used to find current and original versions of XML document.


    65) What is SAX?

    Ans) SAX is an interface processing XML documents using events.


    66) Describe the role that XSL can play when dynamically generating HTML pages from a relational database?

    Ans) Even if candidates have never participated in a project involving this type of architecture, they should recognize it as one of the common uses of XML. Querying a database and then formatting the result set so that it can be validated as an XML document allows developers to translate the data into an HTML table using XSLT rules. Consequently, the format of the resulting HTML table can be modified without changing the database query or application code since the document rendering logic is isolated to the XSLT rules.


    67) Give a few examples of types of applications that can benefit from using XML.

    Ans)There are literally thousands of applications that can benefit from XML technologies. The point of this question is not to have the candidate rattle off a laundry list of projects that they have worked on, but, rather, to allow the candidate to explain the rationale for choosing XML by citing a few real world examples. For instance, one appropriate answer is that XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.


    68) What is SOAP and how does it relate to XML?

    Ans) 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.


    69) Can you walk us through the steps necessary to parse XML documents?

    Ans) Superficially, this is a fairly basic question. However, the point is not to determine whether candidates understand the concept of a parser but rather have them walk through the process of parsing XML documents step-by-step. Determining whether a non-validating or validating parser is needed, choosing the appropriate parser, and handling errors are all important aspects to this process that should be included in the candidate's response.


    70) Give some examples of XML DTDs or schemas that you have worked with.

    Ans) Although XML does not require data to be validated against a DTD, many of the benefits of using the technology are derived from being able to validate XML documents against business or technical architecture rules. Polling for the list of DTDs that developers have worked with provides insight to their general exposure to the technology. The ideal candidate will have knowledge of several of the commonly used DTDs such as FpML, DocBook, HRML, and RDF, as well as experience designing a custom DTD for a particular project where no standard existed.


    71) Using XSLT, how would you extract a specific attribute from an element in an XML document?

    Ans) <xsl:template match="element-name"> Attribute Value: <xsl:value-of select="@attribute"/> <xsl:apply-templates/> </xsl:template>


    72)In What case you are not going to use XML?

    Ans) XML is verbose and it can be 5-8 times larger in size compared to a CSV or a tab-delimited file. If your network has less bandwidth and your content is too large and your network throughput is vital to the application then you can consider tab or csv delimited format instead of XML.


    73) What I XMLA?

    Ans) It is a protocol of Microsoft for XML-messaging used for exchanging data between client and servers.


    74) Why is XML such an important development?

    Ans) It removes two constraints which were holding back Web developments: dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for

  • 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 formatfor 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.

  • 75) Differences Between XML and HTML

    Ans) 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 require

  • 76)What is a Processing Instruction in XML?

    Ans) A ProcessingIntruction is the information which we would like to give to application. Through a ProcessingInstruction an application would get idea about how to process the document. A ProcessingInstruction can appear anywhere and any no. of times in a document.


    77) What is the relevance of ElementFormDefault attribute in the Schema?

    Ans) ElementFormDefault indicates whether or not locally declared elements must be qualified by the target namespace in an instance document. ElementFormDefault attribute in the Schema has the following relevance:

  • Qualified: Each and every element of the Schema must be qualified with the namespace in the instance document.
  • Unqualified: means only globally declared elements must be qualified with there namespace and not the local elements

  • 78) What are the interfaces of SAX

    Ans) The interfaces of SAX are:

  • DocumentHandler- is used for getting event notification relating to a document.
  • DTDHandler- is implemented to get the notifications related to declarations in DTD like entities and notations
  • EntityResolver- is used for reading external entities.
  • ErrorHandler- is used for handling error related notifications

  • 79) What is the role of XSL transformer?

    Ans) An XSL transformer will transform in the following way:

  • The source tree is obtained by parsing in a normal XML style
  • The transformation is now applied to the source with the help of information available in Stylesheet.
  • 80) What is XSL template?

    Ans) Template specifies transformation rules. A Stylesheet document can be made up of at least one template, which acts as an entry point. Every template uniquely identifies a particular node in the source tree.


    81) What is XSL-FO?

    Ans) XSL-FO deals with formatting XML data. This can be used for generating output in a particular format like XML to PDF, XML to DOC, etc


    82) Who Is Responsible For Xml?

    Ans) XML is a project of the World Wide Web Consortium (W3C), and the development of the specification is supervised by an XML Working Group. A Special Interest Group of co-opted contributors and experts from various fields contributed comments and reviews by email. XML is a public format: it is not a proprietary development of any company, although the membership of the WG and the SIG represented companies as well as research and academic institutions. The v1.0 specification was accepted by the W3C as a Recommendation on Feb 10, 1998.


    83) Why Not Just Carry On Extending Html?

    Ans) THTML 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.


    84) Can I Use Java To Create Or Manage Xml Files?

    Ans) Yes, any programming language can be used to output data from any source in XML format. There is a growing number of front-ends and back-ends for programming environments and data management environments to automate this. Java is just the most popular one at the moment. There is a large body of middleware (APIs) written in Java and other languages for managing data either in XML or with XML input or output.


    85) How Does Xml Handle Metadata?

    Ans) Because XML lets you define your own markup languages, you can make full use of the extended hypertext features of XML (see the question on Links) to store or link to metadata in any format (eg using ISO 11179, as a Topic Maps Published Subject, with Dublin Core, Warwick Framework, or with Resource Description Framework (RDF), or even Platform for Internet Content Selection (PICS)). There are no predefined elements in XML, because it is an architecture, not an application, so it is not part of XML's job to specify how or if authors should or should not implement metadata. You are therefore free to use any suitable method. Browser makers may also have their own architectural recommendations or methods to propose.


    86) How Do I Get Xml Into Or Out Of A Database?

    Ans) Ask your database manufacturer: they all provide XML import and export modules to connect XML applications with databases. In some trivial cases there will be a 1:1 match between field names in the database table and element type names in the XML Schema or DTD, but in most cases some programming will be required to establish the desired match. This can usually be stored as a procedure so that subsequent uses are simply commands or calls with the relevant parameters. In less trivial, but still simple, cases, you could export by writing a report routine that formats the output as an XML document, and you could import by writing an XSLT transformation that formatted the XML data as a load file.


    87) Can A Root Element Type Be Explicitly Declared In The Dtd?

    Ans) No. This is done in the document's Document Type Declaration, not in the DTD.


    88)Does Xml Let Me Make Up My Own Tags?

    Ans) No, it lets you make up names for your own element types. If you think tags and elements are the same thing you are already in considerable trouble: read the rest of this question carefully.


    89) Xlink Markup Design?

    Ans) Link markup needs to be recognized reliably by XLink applications in order to be traversed and handled properly. XLink uses the mechanism described in the Namespaces in XML Recommendation [XML Names] to accomplish recognition of the constructs in the XLink vocabulary.


    90) What About Non-xml Resources?

    Ans) You can use the XPointer Framework with non-XML resources. This is especially effective when your resource is backed by some kind of a DBMS, or when you want to query a data model, such as RDF, and not the XML syntax of a representation of that data model. However, please note that the authoratitive interpretation of the fragment identifier is determined by the Internet Media Type. If you want to opt-in for XPointer, then you can always create publish your own Internet Media Type with IANA and specify that it supports the XPointer Framework for some kind of non-XML resource. ' In this case, you are going to need to declare your own XPointer schemes as well.


    91) Can I Use A Relative Uri As A Namespace Name?

    Ans) Yes. However, such usage is deprecated, so you should never do it


    92) Can I Resolve The Uri Used As An Xml Namespace Name?

    Ans) Yes


    93) What Is A Qualified Name?

    Ans) A qualified name is a name of the following form. It consists of an optional prefix and colon, followed by the local part, which is sometimes known as a local name. prefix:local-part


    94)What Software Is Needed To Process Xml Namespaces?

    Ans)Most XML documents are written in a specific XML language and processed by an application that understands that language. If the language uses an XML namespace, then the application will already use that namespace — there is no need for any special XML namespace software.


    95) What Is The Scope Of An Xml Namespace Declaration?

    Ans)The scope of an XML namespace declaration is that part of an XML document to which the declaration applies. An XML namespace declaration remains in scope for the element on which it is declared and all of its descendants, unless it is overridden or undeclared on one of those descendants.

    96) Can I Use Qualified Names In Dtds?

    Ans) Yes. For example, the following is legal: <!ELEMENT google:A (google:B)> <!ATTLIST google:A google:C CDATA #IMPLIED> <!ELEMENT google:B (#PCDATA)> However, because XML namespace declarations do not apply to DTDs , qualified names in the DTD cannot be converted to universal names. As a result, qualified names in the DTD have no special meaning. For example, google:A is just google:A — it is not A in the XML namespace to which the prefix google is mapped. The reason qualified names are allowed in the DTD is so that validation will continue to work.


    97) How Do I Undeclare The Default Xml Namespace?

    Ans) To “undeclare” the default XML namespace, you declare a default XML namespace with an empty (zero-length) name (URI). Within the scope of this declaration, unprefixed element type names do not belong to any XML namespace. For example, in the following, the default XML namespace is the http://www.google.org/ for the A and B elements and there is no default XML namespace for the C and D elements. That is, the names A and B are in the http://www.google.org/ namespace and the names C and D are not in any XML namespace. <A xmlns=”http://www.google.org/”> <B> <C xmlns=”"> <D>abcd</D> </C> </B> </A>


    98) Explain About Soap?

    Ans) SOAP acts as a medium to provide basic messaging framework. On these basic messaging frameworks abstract layers are built. It transfers messages across the board in different protocols; it also acts as a medium to transmit XML based messages over the network.


    99) Explain About Remote Call Procedure?

    Ans) Remote call procedure is considered as a very important function in SOAP. In RCP a user (node) sends a request to another node (server) where the information is processes and sent to the user. It immediately sends message across the network.


    100) What Are The Elements Which Should Be Contained In Soap Message?

    Ans) Following elements are contained in the SOAP message.
    1) An envelope element which identifies and translates the XML document into a SOAP message.
    2) A header element is a must as it should contain header message.
    3) A body is required which should contain call and response message.
    4) Fault element is required which can communicate about the errors occurred during the process