XML Interview Questions and Answers – 2

51. How Would You Build A Search Engine For Large Volumes Of Xml Data?
The way candidates answer this 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.

52. 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.

53. Do I Have To Know Html Or SGML Before I Learn Xml?
No, although it’s useful because a lot of XML terminology and practice derives from two decades’experience of SGML. Be aware that ‘knowing HTML’ is not the same as ‘understanding SGML’. Although HTML was written as an SGML application, browsers ignore most of it (which is why so many useful things don’t work), so just because something is done a certain way in HTML browsers does not mean it’s correct, least of all in XML.

54. Is There An Xml Version Of Html?
Yes, the W3C recommends using XHTML which is ‘a reformulation of HTML 4 in XML 1.0’. This specification defines HTML as an XML application, and provides three DTDs corresponding to the ones defined by HTML 4.* (Strict, Transitional, and Frameset).
The semantics of the elements and their attributes are as defined in the W3C Recommendation for HTML 4. These semantics provide the foundation for future extensibility of XHTML. Compatibility with existing HTML browsers is possible by following a small set of guidelines

55. If Xml Is Just A Subset Of SGML , Can I Use Xml Files Directly With Existing SGML Tools?
Yes, provided you use up-to-date SGML software which knows about the WebSGML Adaptations TC to ISO 8879 (the features needed to support XML, such as the variant form for EMPTY elements; some aspects of the SGML Declaration such as NAMECASE GENERAL NO; multiple attribute token list declarations, etc).
An alternative is to use an SGML DTD to let you create a fully-normalised SGML file, but one which does not use empty elements; and then remove the DocType Declaration so it becomes a well-formed DTDless XML file. Most SGML tools now handle XML files well, and provide an option switch between the two standards.

56. How Do I Configure An Xpointer Processor?
There is no required configuration for the XPointer Framework. The uberjar command line utility provides some configuration options. Applications configure individual XPointer processors when they obtain an instance from an appropriate XPointerProcessor factory method.

57. What are XML Namespaces?
XML namespaces are used to avoid element name conflicts, and it can be avoided by using prefix before the name.

58. Who Can Create An Xml Namespace?
Anybody can create an XML namespace — all you need to do is assign a URI as its name and decide what element type and attribute names are in it. The URI must be under your control and should not be being used to identify a different XML namespace, such as by a coworker.

59. Do Xml Namespaces Apply To Entity Names, Notation Names, Or Processing Instruction Targets?
No, XML namespaces apply only to element type and attribute names. Furthermore, in an XML document that conforms to the XML namespaces recommendation, entity names, notation names, and processing instruction targets must not contain colons.

60. Are The Names Of All Element Types And Attributes In Some Xml Namespace?
No., If an element type or attribute name is not specifically declared to be in an XML namespace — that is, it is unprefixed and (in the case of element type names) there is no default XML namespace — then that name is not in any XML namespace. If you want, you can think of it as having a null URI as its name, although no “null” XML namespace actually exists. For example, in the following, the element type name B and the attribute names C and E are not in any XML namespace:

<google:A xmlns:google="http://www.google.org/">
<B C="bar"/>
<google:D E="bar"/>
</google:A>

61. How Does An Application Know Which Address Element Type It Is Processing?
One solution is to simply rename one of the Address element types — for example, we could rename the second element type IPAddress. However, this is not a useful long term solution. One of the hopes of XML is that people will standardize XML languages for various subject areas and write modular code to process those languages. By reusing existing languages and code, people can quickly define new languages and write applications that process them. If we rename the second Address element type to IPAddress, we will break any code that expects the old name. A better answer is to assign each language (including its Address element type) to a different namespace. This allows us to continue using the Address name in each language, but to distinguish between the two different element types. The mechanism by which we do this is XML namespaces. Note that by assigning each Address name to an XML namespace, we actually change the name to a two-part name consisting of the name of the XML namespace plus the name Address. This means that any code that recognizes just the name Address will need to be changed to recognize the new two-part name. However, this only needs to be done once, as the two-part name is universally unique.

62. How Can I Include A Conditional Statement In My Xml?
We cannot include conditional statement as like programming language.

<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>

63. Is it possible to use graphics in XML?
There is a way to include graphics i.e. using XLink and XPointer. There are several graphics formats that it supports such as GIF, JPG, TIFF, PNG, CGM, EPS, and SVG.

Xlink:

<description
xlink:type="simple"
xlink:href="http://show.com/Cinema.gif"
xlink:show="new">
</description>

XPointer:

<description
xlink:type="simple"
xlink:href="http://show.com/Cinema.gif#Shownumber"
xlink:show="new">
</description>

64. What is XLink and XPointer?
XLink is the standard way of creating hyperlinks in the XML files. Xpointer which allows those hyperlinks to point to more specific parts of the XML file or document.

65. Define the concept of XPOINTER.
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.
See this example:

address.xml#pointer(/ descendant ::streetnumber[@id =9])

In this example, XPOINTER points “streetnumber = 9” in “address.xml”.

66. What is XML data binding? Why is it used?
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.

67. What is XML Encoding?
XML documents may contain Non-ASCII characters like French and Norwegian characters. XML Encoding is used to avoid errors and XML files have to be saved as Unicode.

68. What is XML encoding error?
There are two types of XML encoding errors:
1. An invalid character was found in text content.
2. 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.

69. What are the different XML API’s?
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.

70. What is XmlReader class? Explain.
The XmlReader 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;

71. What does SVG stand for and what is it used for?
SVG stands for Scalable Vector Graphics. It is an XML language that is used to display animations, images, graphics, and 2D from the XML code. Vector mathematical formulas are used here to render the content.

72. How Do I Use Graphics In Xml?
Graphics have traditionally just been links which happen to have a picture file at the end rather than another piece of text. They can therefore be implemented in any way supported by the XLink and XPointer specifications including using similar syntax to existing HTML images. They can also be referenced using XML’s built-in NOTATION and ENTITY mechanism in a similar way to standard SGML, as external unparsed entities.
However, the SVG specification lets you use XML markup to draw vector graphics objects directly in your XML file. This provides enormous power for the inclusion of portable graphics, especially interactive or animated sequences, and it is now slowly becoming supported in browsers.
The XML linking specifications for external images give you much better control over the traversal and activation of links, so an author can specify, for example, whether or not to have an image appear when the page is loaded, or on a click from the user, or in a separate window, without having to resort to scripting.
XML itself doesn’t predicate or restrict graphic file formats: GIF, JPG, TIFF, PNG, CGM, EPS, and SVG at a minimum would seem to make sense; however, vector formats (EPS, SVG) are normally essential for non-photographic images (diagrams).
You cannot embed a raw binary graphics file (or any other binary [non-text] data) directly into an XML file because any bytes happening to resemble markup would get misinterpreted: you must refer to it by linking (see below). It is, however, possible to include a text-encoded transformation of a binary file as a CDATA Marked Section, using something like UUencode with the markup characters ], & and > removed from the map so that they could not occur as an erroneous CDATA termination sequence and be misinterpreted. You could even use simple hexadecimal encoding as used in PostScript. For vector graphics, however, the solution is to use SVG .
Sound files are binary objects in the same way that external graphics are, so they can only be referenced externally. Music files written in MusiXML or an XML variant of SMDL could however be embedded in the same way as for SVG.
The point about using entities to manage your graphics is that you can keep the list of entity declarations separate from the rest of the document, so you can re-use the names if an image is needed more than once, but only store the physical file specification in a single place. This is available only when using a DTD, not a Schema.

73. How Do I Control Formatting And Appearance?
In HTML, default styling was built into the browsers because the tagset of HTML was predefined and hardwired into browsers. In XML, where you can define your own tagset, browsers cannot possibly be expected to guess or know in advance what names you are going to use and what they will mean, so you need a stylesheet if you want to display formatted text. Browsers which read XML will accept and use a CSS stylesheet at a minimum, but you can also use the more powerful XSLT stylesheet language to transform your XML into HTML—which browsers, of course, already know how to display (and that HTML can still use a CSS stylesheet). This way you get all the document management benefits of using XML, but you don’t have to worry about your readers needing XML smarts in their browsers.

74. How Do I Execute Or Run An Xml File?
XML itself is not a programming language, so XML files don’t ‘run’ or ‘execute’. XML is a markup specification language and XML files are just data: they sit there until you run a program which displays them (like a browser) or does some work with them (like a converter which writes the data in another format, or a database which reads the data), or modifies them (like an editor). If you want to view or display an XML file, open it with an XML editor or an B.3, XML browser. The water is muddied by XSL (both XSLT and XSL:FO) which use XML syntax to implement a declarative programming language. In these cases it is arguable that you can ‘execute’ XML code, by running a processing application like Saxon, which compiles the directives specified in XSLT files into Java bytecode to process XML.

75. Why should we go for XML editor instead of Notepad?
XML editors allow building an error-proof XML document which is then validated against either of the two i.e. Schema or DTD. There are several reasons to use XML editors because they can check both open and closed tags, they can validate against DTD and Schema. The editor can also check the color code on a syntax of XML.

76. Can I Use Javascript, Activex, Etc In Xml Files?
This will depend on what facilities your users’ browsers implement. XML is about describing information; scripting languages and languages for embedded functionality are software which enables the information to be manipulated at the user’s end, so these languages do not normally have any place in an XML file itself, but in stylesheets like XSL and CSS where they can be added to generated HTML. XML itself provides a way to define the markup needed to implement scripting languages: as a neutral standard it neither encourages not discourages their use, and does not favour one language over another, so it is possible to use XML markup to store the program code, from where it can be retrieved by (for example) XSLT and re-expressed in a HTML script element. Server-side script embedding, like PHP or ASP, can be used with the relevant server to modify the XML code on the fly, as the document is served, just as they can with HTML. Authors should be aware, however, that embedding server-side scripting may mean the file as stored is not valid XML: it only becomes valid when processed and served, so care must be taken when using validating editors or other software to handle or manage such files. A better solution may be to use an XML serving solution like Cocoon, AxKit, or PropelX.

77. Can I Use Java To Create Or Manage Xml Files?
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.

78. How Does Xml Handle Metadata?
Because XML lets you define your own markup languages, you can make full use of the extended hypertext features of XML 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.

79. Can I Encode Mathematics Using Xml ?
Yes, if the document type you use provides for math, and your users’ browsers are capable of rendering it. The mathematics-using community has developed the MathML Recommendation at the W3C, which is a native XML application suitable for embedding in other DTDs and Schemas. It is also possible to make XML fragments from other DTDs, such as ISO 12083 Math, or OpenMath, or one of your own making. Browsers which display math embedded in SGML existed for many years (eg DynaText, Panorama, Multidoc Pro), and mainstream browsers are now rendering MathML. David Carlisle has produced a set of stylesheets for rendering MathML in browsers. It is also possible to use XSLT to convert XML math markup to LATEX for print (PDF) rendering, or to use XSL:FO. Please note that XML is not itself a programming language, so concepts such as arithmetic and if-statements (if-then-else logic) are not meaningful in XML documents.

80. How Do I Get Xml Into Or Out Of A Database?
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.

81. Can A Root Element Type Be Explicitly Declared In The Dtd?
No. This is done in the document’s Document Type Declaration, not in the DTD.

82. Is XML case sensitive?
Yes, XML is a case sensitive language.

83. What is the meaning of well-formed XML?
A well-formed XML means an XML document that is syntactically correct e.g. it has a root element, all open tags are closed properly, attributes are in quotes, etc. If an XML is not well-formed, it may not be processed and parsed correctly by various XML parsers.
Well-formed XML documents have the following features:
• An XML document must have a root element.
• XML tags are case sensitive.
• XML elements should be properly nested.
• XML values should be properly quoted.
• XML tags should be closed properly.

84. What is XML Parser?
XML Parser is used to convert from XML document into an XML DOM object which can be written in Javascript.

85. What are the types of XML Parsers?
The XML parsers are of two types i.e. Non-Validating and Validating. If it’s a validating parser, it will validate XML against DTD and if its non-validating, it will not validate XML against DTD.

86. What do you mean by nested elements in XML?
When root elements nest one or two elements, its called nested elements. Through nesting, an XML document can be kept in order and makes it easier to understand.

87. How Do I Create My Own Document Type?
Document types usually need a formal description, either a DTD or a Schema. Whilst it is possible to process well-formed XML documents without any such description, trying to create them without one is asking for trouble. A DTD or Schema is used with an XML editor or API interface to guide and control the construction of the document, making sure the right elements go in the right places.
Creating your own document type therefore begins with an analysis of the class of documents you want to describe: reports, invoices, letters, configuration files, credit-card verification requests, or whatever. Once you have the structure correct, you write code to express this formally, using DTD or Schema syntax.

88. What is a valid XML document?
A structurally correct element is called a valid XML document. It should follow some predefined rules of a specific type of document. These rules determine the type of data that each part of the document can contain. These rules can be written by the author of an XML document or someone other.

89. Can XML be used for multimedia purposes?
Yes, XML can be used for multimedia purposes by using SVG and SMIL.

90. Does Xml Let Me Make Up My Own Tags?
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 carefully.

91. Xlink Markup Design
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.

92. What is XML Signature?
XML signature is also known as a digital signature that is W3C recommended. There are two types of signature i.e. detached signature when the document has it outside and enveloping signature when it’s placed inside.

93. What is Data Island?
An XML Data island is XML data embedded into a HTML page. This works only with the Internet.

94. What Three Essential Components Of Security Does The Xml Signatures Provide?
Authentication, Message Integrity, and Non-Repudiation. In addition to signature information, an XML Signature can also contain information describing the key used to sign the content.

95. What’s Xlink?
This specification defines the XML Linking Language (XLink), which allows elements to be inserted into XML documents in order to create and describe links between resources. It uses XML syntax to create structures that can describe links similar to the simple unidirectional hyperlinks of today’s HTML, as well as more sophisticated links. Xlink used in XML files, are the standard way of creating hyperlinks in XML files.

96. What Xpointer Schemes Are Supported In This Release?
The XPointer integration distributions support shorthand pointers.
In addition, they bundle support for at last the following XPointer schemes:
• xmlns()
• element()
• xpath() – This is not a W3C defined XPointer scheme since W3C has not published an XPointer sheme for XPath.

97. What About Non-xml Resources?
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.

98. Can I Resolve The Uri Used As An Xml Namespace Name?
Yes.

99. Can I Use A Relative Uri As A Namespace Name?
Yes. However, such usage is deprecated, so you should never do it.

100. What Is An Xml Namespace Name?
An XML namespace name is a URI that uniquely identifies the namespace. URIs are used because they are widely understood and well documented. Because people may only allocate URIs under their control, it is easy to ensure that no two XML namespaces are identified by the same URI.

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *


three + 8 =

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter