Saturday, July 5, 2008

XML Questions 2

16.What is the relevance of ElementFormDefault attribute in the Schema?

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.


17.What is XML parser?

An XML parser is a piece of software which can do following:

* Check for well-formedness
* Validate the document
* Allows us to read, create or modify existing XML documents

Note: Parser is piece of software provided by vendors. An XML parser is built in Java runtime from JDK 1.4 onwards


18.What is DOM?

The Document Object Model (DOM) is a platform and language-independent standard object model for representing XML and related formats. DOM is standard API which is not specific to any programming language. DOM represents an XML document as a tree model. The tree model makes the XML document hierarchal by nature. Each and every construct of the XML document is represented as a node in the tree.


19.What is SAX?

SAX-Simple API for XML processing. SAX provides a mechanism for reading data from an XML document. It is a popular alternative to the Document Object Model (DOM).SAX provides an event based processing approach unlike DOM which is tree based.


20.What are the interfaces of SAX?

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.

21.What is the difference between SAX parser and DOM parser?

SAX DOM
A SAX parser takes the occurrences of components of an input document as events (i.e., event based processing), and tells the client what it reads as it reads through the input document. A DOM parser creates a tree structure in memory from an input document and then waits for requests from client.
No navigation possible (top to bottom only once) Whereas, we can navigate the DOM tree in any direction, any no. of times.
We cannot modify the document content in SAX We can modify the document content in DOM
A SAX parser serves the client application always only with pieces of the document at any given time. A DOM parser always serves the client application with the entire document no matter how much is actually needed by the client.
A SAX parser, however, is much more space efficient in case of a big input document A DOM parser is space inefficient when the document is huge.

Use SAX parser when

  • Input document is too big for available memory.
  • When only a part of the document is to be read and we create the data structures of our own.
  • If you use SAX, you are using much less memory and performing much less dynamic memory allocation.

Use DOM when

  • Your application has to access various parts of the document and using your own structure is just as complicated as the DOM tree.
  • Your application has to change the tree very frequently and data has to be stored for a significant amount of time.

22.What is a CDATA section in XML?

CDATA Sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. All tags and entity references are ignored by an XML processor that treats them just like any character data. CDATA blocks have been provided as a convenience measure when you want to include large blocks of special characters as character data, but you do not want to have to use entity references all the time.


23.What is XSL?

eXtensible Stylesheet Language(XSL) deals with most displaying the contents of XML documents.XSL consists of three parts:

  • XSLT - a language for transforming XML documents
  • XPath - a language for navigating in XML documents
  • XSL-FO - a language for formatting XML documents

24.How is XSL different from Cascading Style Sheets? Why is a new Stylesheet language needed?

XSL is compatible with CSS and is designed to handle the new capabilities of XML that CSS can't handle. XSL is derived from Document Style Semantics and Specification Language (DSSSL), a complex Stylesheet language with roots in the SGML community. The syntax of XSL is quite different from CSS, which could be used to display simple XML data but isn't general enough to handle all the possibilities generated by XML. XSL adds the capability to handle these possibilities. For instance, CSS cannot add new items or generated text (for instance, to assign a purchase order number) or add a footer (such as an order confirmation). XSL allows for these capabilities.

25.What is XSLT?

eXtensible Stylesheet Language Transformation (XSLT) deals with transformation of one XML document into XHTML documents or to other XML documents. XSLT uses XPath for traversing an XML document and arriving at a particular node.

XSLT

Figure 3: XSLT


26.What is the role of XSL transformer?

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.

27.What is the structure of XSLT?
XSLT Structure

Figure 4: XSLT Structure

28.What is XSL template?

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.


29.What is XPath?

XPath is an expression language used for addressing parts of an XML document. XPath is used to navigate through elements and attributes in an XML document.


30.What is XSL-FO?

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.

31.How XSL-FO Works (or) How would you produce PDF output using XSL’s?
XSLT FO

Figure 5: XSL-FO




1 comment:

Anonymous said...

You may also want to look at vtd-xml,the latest and most advanced xml technology

http://vtd-xml.sf.net

Topics