Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

XML Interview

Difference between XML and HTML:
HTML is Presentation Language, it is not case sensitive, every
tag need not have an ending tag, we cannot write our own Tags.In XML, Every tag must have an ending tag, We can write our own tags, It is case sensitive.

XML and Binary Serialization:
XMLSerialization is called Shallow Serialization because it can serialize only
public fieldsSoap Serialization and Binary Serialization techniques are called Deep Serialization because it serialize the object containing reference.

How would you build a search engine for large volumes of XML data?
The way candidates answer this question may provide insight into their view of XML data. For those who view XML primarily as a way to denote structure for text files, a common answer is to build a full-text search and handle the data similarly to the way Internet portals handle HTML pages. Others consider XML as a standard way of transferring structured data between disparate systems. These candidates often describe some scheme of importing XML into a relational or object database and relying on the database's engine for searching. Lastly, candidates that have worked with vendors specializing in this area often say that the best way the handle this situation is to use a third party software package optimized for XML data.
Obviously, some important areas of XML technologies were not included in this list -- namespaces, XPointer, XLink, and so on -- and should be added to the interviewer's set of questions if applicable to the particular position that the candidate is applying for. However, these questions in conjunction with others to assess soft skills (communication skills, ability to work on teams, leadership ability, etc.) will help determine how well candidates understand the fundamental principles of XML.
What is XQuery?
Xquery is a query language that is used to retrieve data from XML documents.
XQuery is a way to query the XML data, It is built on XPath expressions and is supported by quite a few database engines.
It can find and extract elements and attributes from XML documents.
XQuery is written in FLWOR fashion which stands for: For, Let, Where, Order by, Return
An example of XQuery is:for $x in doc("abc.xml")/abc_namewhere $x/a>30order by $x/breturn $x/c.

What is XPATH?
XPath is a language that describes how to locate specific elements (and attributes, processing instructions, etc.) in a document.
An XSL sublanguage designed to uniquely identify or address parts of a source XML document, for use with XSLT.
It is based on a tree representation of XML document. It provides the ability to navigate around the tree and to select the nodes by a variety of criteria.
The simplest XPath is /A/B/C where C is the child of B, B child of A.
What is a CDATA section in XML?
CDATA - (Unparsed) Character DataThe term CDATA is used when you dont want some text data to be parsed by the XML parser.
A CDATA section starts with "":
What is XSL?
XSL is a language for expressing style sheets. An XSL style sheet is a file that describes the way to display an XML document.
Using XSL stylesheets, we can separate the XML document content and its styling.
An XSL style sheet begins with the XML declaration: defines that the document is an XSLT style sheet document.The element defines a template.
Define CSS and XSL.
XSL is a language for expressing style sheets. An XSL style sheet is a file that describes the way to display an XML document.
Cascading Style Sheets is an answer to the limitations of HTML, where the structure of documents was defined and not the display. CSS formats documents for display in browsers that support it.

How do you display XML with XSLT?
First you need to declare the XSL style sheet:

Then,you create an XSL Style Sheet with a transformation template.Add the XSL style sheet reference to your XML document to link them.
What is XMLA ?
XML for Analysis, It is a Microsoft specified XML-messaging-based protocol for exchanging analytical data between client applications and servers using HTTP and SOAP as a service on the Web.
What is XML Namespace?
An XSL sheet or a document may have duplicate elements and attributes. Therefore, the XML namespaces define a way to distinguish between duplicate element types and attribute names.An XML namespace is a collection of element type and attribute names. It is a URI due to which any element type or attribute name in an XML namespace can be uniquely identified. It consists of two parts : the name of the XML namespace and the local name.
e.g.: xmlns: h=”http://www.abc.com”After this, you can write……..to associate the table with the declared namespace.
What is XML data binding?
XML data binding refers to the process of representing the information in an XML document as an object in computer memory.
The limitations of data binding include round tripping of elements and attributes. XML data binding product generates documents that are invalid because of sibling order. They do not preserve physical constructs. They do not preserve comments and processing instructions.
What is XML Serialization and Binary Serialization?
XML Serialization makes it possible to convert any common language runtime objects into XML documents or streams and vise versa.
The XML Serialization enables it to convert XML documents into such a meaningful format that the programming languages can process the converted documents with ease.
Binary serialization converts the files to a binay format. In this case all the data get converted into a binary format which is not a human readable format. In binary serialization entire object state is saved, instance identity is preserved and it graphs with multiple references can be handled in this.
XML serialization doesnt allow these things.
What are XML indexes and secondary XML indexes?
The primary XML index is a B+tree and is useful because the optimizer creates a plan for the entire query.
It is always better to split the entire XML columns into relational rows and columns.
The primary XML index contains one row for each node in the XML instance.
The secondary XML indexes can be created to enhance the performance.There are the types of secondary indexes:
PATH secondary XML indexIf the use of path expressions on XML columns is prominant, the PATH secondary XML index can speed up the task.
VALUE secondary XML indexThe VALUE index can be used if your task involves quering unknown attribute names.
PROPERTY secondary XML indexClustering paths within each XML instance in the PROPERTY index can be beneficial when multiple values are retrieved from individual XML instances.
List the rules to be followed by an XML document.
Following rules need to be followed by an XML document:
They must have a root tag, the document should be well formed : the tags should be properly closed, since XML is case sensitive, one should take care that the documents are written with proper care and the attribute values should be inside “”
Explain about XML Canonicalization.
AnswerCanonicalization refers to finding the simplified form of an XML document.
XML files may not contain the same sequence of characters (bytes or octets) even if they are logically equivalent. This is where we need to canonicalize them and check their canonical forms.
Steps to canonicalize an XML document
Encoding schemes should represent characters by octets.XML documents should be encoded in UTF-8 encoding.
The canonical form needs all line breaks to be #xA.
All attributes need to be normalized in canonical form.
What is the XMLHttpRequest Object?
The XMLHttpRequest object is used to connect to the server through http. Scripts use it to do so programmatically.
The EventTarget interface needs to be implemented if an object implements the XMLHttpRequest interface. Also, an XMLHttpRequest() constructor needs to be provided by objects that implement the Window interface.

Explain common XMLHttpRequest Object Properties. i.e. onreadystatechange, readyState, responseText, responseXML, status, statusText.
The ‘onreadystatechange’ property fires at every state change event.
The ‘readyState’ property is an object status integer. It uses the integers 0 to 4 for uninitialized, loading, loaded, interactive and complete states.
The ‘responseText’ property is a string version of data returned from server process.
The ‘responseXML’ property is DOM-compatible document object of data returned from server process.
The ‘status’ property is for returning numeric codes from the server like error codes, etc.
The ‘statusText’ property is used for string messages that accompany the status code.

Explain common XMLHttpRequest Object Methods.
The abort() is used to stop the current request.
The getAllResponseHeaders() method is used to return the full set of headers as a string.
The getResponseHeader("headerLabel") method is used to return the string value of a single header label.
The open("method", "URL"[, asyncFlag[, "userName"[, "password"]]]) is used to assign the destination URL, method, and other optional attributes of a request.
The send(content) method transmits the request, optionally with postable string or the data of DOM object.
The setRequestHeader("label", "value") method is used to assign a label/value pair to the header to be sent with a request.
Why the need for XHTML?
If a script in an HTML document is not well formed, small devices like mobile phones fail to display the content properly. Also, upgrading all the browsers to support XML is a timely affair. An intermediate solution is XHTML that is a combination of HTML and XML. In XTML the content has to be well formed so that there is no bad HTML.

XHTML vs HTML
XHTMLElements must be properly nestedElements must be closedElements must be in lowercaseDocuments must have one root element
HTMLElements need not be properly nestedElements need not be always closedElements need not be in lowercaseDocuments need not have one root element.

Explain the XHTML syntax rules.
Some Syntax rules that need to be followed with XHTML are:
That Attribute names must be in lower case, their values must be in quotes and their minimization is done away from usage.
Also the ‘name’ attribute has been replaced by the ‘id’ attribute. The XHTML DTD defines mandatory elements.
Explain XML Attributes with an example.
The attributes in XML provide additional information about elements. Take a look at the following example:

XML Elements vs. Attributes.
XML elements as well as attributes can be used to provide the same information about an entity in an XML database. The only difference lies in the way they are written. For example:
..... is an example of using attributes. The same information can be provided in the element form as follows:Da Vinci Code.

What are the problems with using XML attributes?
It is preferred storing the data using the XML elemental form as it becomes very convenient to access and modify the data. Also the use of attributes is limited as they cannot contain multiple values, cannot contain tree structures nor are expandable.
What is the DOM?
DOM is a platform independent, World Wide Web Consortium (W3C) standard form of representation of structured documents as an object-oriented model. It is an application programming interface so as to access HTML and XML documents.

What is the HTML DOM?
The HTML DOM API specializes and adds the functionality to relate to HTML documents and elements. It addresses the issues of backwards compatibility with the Level 0 of DOM and provides mechanisms for common and frequent operations on HTML documents.

What is the XML DOM?
Microsoft’s MSXML DOM provides an API for working with XML data. It also provides a programmatic representation of XML documents, fragments, nodes, or node-sets. It is a W3C standard form of XML representation. XML DOM objects can be used in XML applications written in C/C++, VB, VBScript and JScript.
What is an XML encoding error?
XML documents can contain non ASCII characters, like Norwegian æ ø å , or French ê è é which introduce errors.
The 2 types are:An invalid character was found in text content.Switch from current encoding to specified encoding not supported.
You can avoid these errors by specifying the XML encoding Unicode.

XML Interview Materials

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.

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.

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.
Give a few examples of types of applications that can benefit from using XML.
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.
Can you walk me through the steps necessary to parse XML documents?
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.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder domBuilder = factory.newDocumentBuilder();
Document doc = domBuilder.parse(XMLFile);

Give some examples of XML DTDs or schemas that you have worked with.
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.

Is it possible to write the contents of org.w3c.dom.Document object into an .xml file?
Yes its possible. One to achieve this is by using Xerces. Xerces is an XML parser. You would use the following code
org.apache.xml.serialize.OutputFormat format = new org.apache.xml.serialize.OutputFormat(myDocument);
org.apache.xml.serialize.XMLSerializer output = new org.apache.xml.serialize.XMLSerializer(new FileOutputStream(new File("test.xml")), format);
output.serialize(myDocument);

What is the difference between DOM and SAX? What would you use if an option is given?
DOM parses an XML document and returns an instance of org.w3c.dom.Document. This document object's tree must then
be "walked" in order to process the different elements. DOM parses the ENTIRE Document into memory, and then makes it
available to you. The size of the Document you can parse is limited to the memory available.

SAX uses an event callback mechanism requiring you to code methods to handle events thrown by the parser as it
encounters different entities within the XML document. SAX throws events as the Document is being parsed. Only the
current element is actually in memory, so there is no limit to the size of a Document when using SAX.

The specific parser technology that will be used will be determined by the requirements of your application. If you need the
entire document represented, you will most likely use DOM builder implementation. If you only care about parts of the
XML document and/or you only need to parse the document once, you might be better served using SAX implementation.

What is SOAP?
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.

What is DOM?
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.

Is it necessary to validate XML file against a DTD?
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.

What is XPath?
XPath stands for XML Path Language
XPath is a syntax for defining parts of an XML document
XPath is used to navigate through elements and attributes in an XML document
XPath contains a library of standard functions
XPath is a major element in XSLT
XPath is designed to be used by both XSLT and XPointer
XPath is a W3C Standard

What is XSL?
XSLT - a language for transforming XML documents
XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML.
Normally XSLT does this by transforming each XML element into an (X)HTML element.

What is a DTD and a Schema?
The XML Document Type Declaration contains or points to markup declarations that provide a grammar for a class of documents. This grammar is known as a
document type definition or DTD.

The DTD can point to an external subset containing markup declarations, or can contain the markup declarations directly in an internal subset, or can
even do both.
A Schema is:
XML Schemas express shared vocabularies and allow machines to carry out rules made by people. They provide a means for defining the structure, content
and semantics of XML documents.
Schemas are a richer and more powerful of describing information than what is possible with DTDs.