Thursday, October 25, 2007

XML Interview Question Part2


11. What is Unicode?

Unicode uses 2 bytes to represent characters, extending from 0 to 65,535. ASCII(American Standard Code for Information Interchange) code uses 1 byte to represent characters, extending from 0 to 255. The Unicodes 0 to 255 correspond to the ASCII 0 to 255 codes. Therefore, Unicode can include many of the symbols commonly used in worldwide character and ideograph sets.

UTF-8 means using a compressed version of Unicode that uses 8 bits to represent characters. UTF-16 is a special encoding that represents UCS(Universal Character System) symbols using 2 bytes to represent characters.

12. How to write XML processing instructions?

The XML processing instructions give commands or information to an application that is processing the XML data; it is application specific. It has the following format:



where is the end of procession instruction, the "target" is the name of the application that is expected to do the processing, and "instructions" is a string of characters that embodies the information or commands for the application to process. Note: there cannot be any space between the initial


An XML file may have multiple processing instructions to tell different applications to do similar things.

13. How XML treats with whitespace?

The spaces, carriage returns, line feeds and tabs are all treated as whitespace in XML. XML document uses the UNIX convention for line endings, which means that lines are ended with a linefeed character only -- ASCII code 10(DOS file uses a pair of ASCII codes 13 and 10). When parsed, that is treated simply as a single linefeed.

If you want to preserve whitespace, use a special attribute xml:space or set attribute to default to indicate it in a element declaration.

14. Is XML tag case-sensitive?

Yes. XML tags are case-sensitive. The start and end tags should be matched exactly.

15. Why do people say that XML is portable?

There are several reasons. First, it is written in a text format, which is readable by both human beings and text-editing software. Second, applications can parse and process XML documents, and human beings can also read them in case there is an error in processing. Third, XML document does not include formatting instructions, it can be displayed in various ways. Keeping data separate from formatting instructions means that the same data can be published to different media.

16. How to let browser display XML file?

There are two ways to do so:

o Use a style sheet to indicate to a browser how you want the content of the elements to be displayed, like Cascading Style Sheet(CSS) or Extensible Style Sheet Language(XSL).

o use a programming language to handle the XML document in programming code,like Java or JavaScript.

17. Which is better to store data using elements or using attributes?

There is no clear-cut to say which is better. It depends on the case. But it is worth noting that too many attributes make documents hard to read and attribute names must be unique. If more than 4 attributes in a tag are used, think about breaking up the tag into a number of enclosed tags.

0 comments:

Advertisement

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com