Q) What is XML?
A) XML, Extensible Markup Language, is an open, text based markup language that provides structural and semantic information to data. XML is a metalanguage that can be used to create other language. It is used to structure and describe data that can be understood by other applications. Using XML, we can separate the user interface from data.
Q) What are the Features of XML ?
A) XML is a generalized markup language that means one can define his/her own tag sets.
A valid XML document contains rules and is self-describing.
The rules that are found in DTD allow the documents to be validated.
Q) Describe the logical structure of XML.
A) XML documents comprise of declaration, elements and comments
XML Declaration
It identifies the version to which XML conforms
<?xml version = "1.0"?*>
Document Type Declaration
It consists of markup code that indicates grammar rules or Document Type Definition (DTD) for the particular class of document.
<! DOCTYPE Car SYSTEM "cr.dtd">
This statement tells the XML processor that the document is of the class Car that conforms the rules specified in the DTD "cr.dtd".
Document element
The document element contains data of an XML document.
Q) Why is XML so popular?
A) Due to the following advantages of using XML, it has become popular:
* It supports Unicode. Therefore documents written in any human language can be communicated.
* Data structures: records, lists and trees can be represented using XML.
* Its format describes structure, field names and their specific values too. Its therefore called self-documenting.
* Its syntax and parsing requirements make the necessary parsing algorithms very simple, efficient, and consistent.
* It can be used as a document storage and processing format.
* It is platform-independent.
Q) Why is XML referred as self-describing data?
A) Text labels inside of XML's syntactic delimiters that cause most people to think that XML is self-describing. But these tags aren't part of XML.Choosing the terms used for tags or naming anything is often a difficult and contentious activity. Everyone naturally creates names that make sense to them.However, XML is not self describing.
Q) Why is XML extensible?
A) Extensibility is another attribute of XML. XML is short of "eXtensible Markup Language. This is so because a developer may easily create his own XML syntax for any applications he wishes to use it for. Any other developer, once having learned how to use his own language's XML parsing routines, can use any XML-based format currently available.
Q) XML is a secured language for information exchange over the network. Explain
A) Applications require a secure exchange of structured data. XML encryption can ensure this by providing end-to-end security as it is iitself a widely used data structuring technology.XML encryption addresses the issues not covered in by the TLS which are encrypting part of the data that is being exchanged and secure sessions between multiple parties.XML Encryption can handle XML as well as binary data.
Q) Explain about XML Canonicalization.
A) Canonicalization 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.
Q) List the rules to be followed by an XML document.
A) 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 ""
Q) Define DTD (Document Type definition).
A) DTD - Document Type Definition defines the legal building blocks of an XML document.
It defines the document structure with a list of legal elements and attributes.
XML DTD is a rule book that an XML document follows. Once DTD is ready, you can create number of XML documents following the same rules specified in the DTD. DTD can be internal or external DTD. The internal DTD is included in the XML document, while external DTD exists outside the content of the documents.
Q) Explain DTD and schema.
A) A DTD provides a list of the elements, attributes, comments, notes, and entities contained in an XML or HTML document and indicates their relationship with each other.
The 'DOCTYPE' tells the browser that it is a Document Type Declaration
Some commonly used attribute types are
* CDATA The value is character data
* ID The value is a unique id
* IDREF The value is the id of another element
* IDREFS The value is a list of other ids
Schema means the organization and the structure of a database.
E.g.: An XML schema is a description of XML document. It is expressed in terms of constraints on the structure and content of documents.
Q) What is a CDATA section in XML?
A) CDATA - (Unparsed) Character Data
The term CDATA is used when you dont want some text data to be parsed by the XML parser.
A CDATA section starts with "<![CDATA[" and ends with "]]>":
Q) What is XSL?
A) 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:
<?xml version="1.0" encoding="ISO-8859-1"?>
< xsl:stylesheet> defines that the document is an XSLT style sheet document.
The < xsl:template> element defines a template.
Q) Define CSS and XSL.
A) 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.
Q) How do you display XML with XSLT?
A) First you need to declare the XSL style sheet:
< xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Then,
you create an XSL Style Sheet with a transformation template.
Add the XSL style sheet reference to your XML document to link them.
Q) What is XQuery?
A) 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_name
where $x/a>30
order by $x/b
return $x/c
Q) What is XMLA ?
A) 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.
Q) What is XPATH?
A) 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
Q) What is DOM?
A) DOM is an interface-oriented Application Programming Interface. It allows for navigation of the entire document. A DOM document can be created by a parser, or can be generated manually by users. Data types in DOM Nodes are abstract. DOM implementations generally require the entire document to be loaded into memory and constructed as a tree of objects before access is allowed. DOM is supported in Java. Its specification is regulated by the World Wide Web Consortium.
Q) Explain the difference between DOM and SAX.
A) SAX parser works incrementally and generates events that are passed to the application. DOM parser reads the whole XML document and returns a DOM tree representation of xml document.In DOM the xml file is arranged as a tree and backward and forward search is possible In SAX traversing in any direction is not possible as Top to bottom approach is used.SAX is essentially an API for reading XML, and not writing it. DOM allows you to read and write.
Q) What is XML Namespace?
A) 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
< h:table>
..
< /h:table>
to associate the table with the declared namespace.
Q) What is XML data binding?
A) 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.
Q) What is an XML encoding error?
A) XML documents can contain non ASCII characters, 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.
Q) What is XML Serialization and Binary Serialization?
A) 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.
Q) What is the purpose of FOR XML in SQL Server?
A) SQL Server 2000 provides the facility to retrieve data in the form of XML with the help of the FOR XML clause appended to the end of a SELECT statement. There are 3 types of FOR XML modes - RAW, AUTO, and EXPLICIT. They all generate a different style of XML document
Q) What is the OPENXML statement in SQL Server?
A) Going through thousands of lines of XML degrades performance to a great extent.This is where the OPENXML function comes into use. It does the parsing work for you quite efficiently.
The syntax of OPENXML is:
OPENXML(idoc int [in],rowpattern nvarchar[in],[flags byte[in]]) [WITH (SchemaDeclaration | TableName)]
OPENXML function is supposed to be used with two system stored procedures:
1.sp_xml_preparedocument
2.sp_xml_removedocuments
Q) What are XML indexes and secondary XML indexes?
A) 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 index
If the use of path expressions on XML columns is prominant, the PATH secondary XML index can speed up the task.
VALUE secondary XML index
The VALUE index can be used if your task involves quering unknown attribute names.
PROPERTY secondary XML index
Clustering paths within each XML instance in the PROPERTY index can be beneficial when multiple values are retrieved from individual XML instances.
Q) What is the DOM?
A) 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.
Q) What is the HTML DOM?
A) 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.
Q) What is the XML DOM?
A) 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.
Q) What is the XMLHttpRequest Object?
A) 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.
Q) What is XSL-FO?
A) XSL-FO stands for Extensible Stylesheet Language Formatting Objects. It is used to format XML data and is also a W3C recommendation.
Q) What is XSL-FO Documents? Explain XSL-FO Documents structure.
A) XSL-FO documents are XML files (.fo / .fob OR .xml - for being accessible by XML editors) with output information about the layout and contents.
Document Structure:
As usual they need to start with the version and the encoding declaration:
< ?xml version="1.0" encoding="ISO-8859-1"? >
< fo:root > < /fo:root >
Namespace attribute can be written as:
< fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" >-----------------Root element of XSL-FO documents. You can have the whole document within these tags.
< fo:layout-master-set > ----------------Contains page templates
< fo:simple-page-master >----------------Contains a single page template
< fo:page-sequence > ------------------------Describes the page contents
Q) What is XSL-FO Processors?
A) XSL-FO processors (e.g. XSL Formatter, Xinc Beta Release, Scriptura) are programs that format XSL document output.
Most of them can also output PDF documents, quality print, HTML etc.
Q) Explain XML Attributes with an example.
A) The attributes in XML provide additional information about elements. Take a look at the following example:
< book name = "Da Vinci Code" >
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:
< book name = "Da Vinci Code" > ..... is an example of using attributes.
The same information can be provided in the element form as follows:
< book >
< name >Da Vinci Code< /name >
< /book >
Q) What are the problems with using XML attributes?
A) 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.
Q) What is XSLT?
A) XSLT stands for XSL Transformations and is a language used to transform XML documents into XHTML documents or to other XML documents.
Q) What are the roles of XSLT?
A) The roles of XSLT are:
XSLT is used to transform an XML document into another XML document such as HTML, etc.
XSLT can be used to add or remove elements and attributes to or from the output file.
XSLT can also be used for rearranging and sorting elements.
It can also be used for performing tests and making decisions about hiding and displaying of elements.
Q) Why the need for XHTML?
A)
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
XHTML
Elements must be properly nested
Elements must be closed
Elements must be in lowercase
Documents must have one root element
HTML
Elements need not be properly nested
Elements need not be always closed
Elements need not be in lowercase
Documents 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.
Q) What is the XMLHttpRequest Object?
A) 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.
Q) Explain common XMLHttpRequest Object Properties. i.e. onreadystatechange, readyState, responseText, responseXML, status, statusText.
A) * 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.
Q) Explain common XMLHttpRequest Object Methods.
A) * 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.
Q) How do you load data from XML file to a ORACLE table?
A) You need to first create a table in oracle that matches with the fields of the XML data.
So to get the XMl into the table, you can create a generic procedure that moves an XML document into a table by converting the elements to Oracle Canonical format.
Oracle Canonical format is as follows:
< ROWSET >
< ROW >
< column_name_1 / >
.
.
< /ROW >
< ROW >
< column_name_1 / >
.
.
< /ROW >
.
.
< /ROWSET >
ROW is used for the table names
ROWSET is used for the XML document
You can get the XML into the canonical form using XSL:
< ?xml version="1.0"? >
< xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
< xsl:template match="/" >
< ROWSET >
< ROW >
< Attribute_name >
< xsl:value-of select="Table_name/Attribute_name" / >
< /Attribute_name >
< /ROW >
< /ROWSET >
< /xsl:template >
< /xsl:stylesheet >
To transform the XML document into the canonical form, you can write a procedure. Make sure you include the line below in your procedure code:
v_rows := DBMS_XMLStore.insertXML(
v_context,
XMLType.transform(p_xml_in, p_xsl_in));
The only remaining step is calling your procedure:
DECLARE
v_xml XMLType := XMLType( YOUR XML Document );
v_xsl XMLType := XMLType( YOUR XSL Document );
BEGIN
procedure_name(v_xml, v_xsl, 'table_name');
END;
Q) Differences Between XML and HTML
A) 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
Q) What is DOM and how does it relate to XML?
A) 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.
Q) What is SOAP and how does it relate to XML?
A) 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.
Q) Give a few examples of types of applications that can benefit from using XML.
A) 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.