M. Farhan wrote:
> Well i have a question on XSL,DOM and SAX,
> 1. where do we use DOM and SAX..if XSLT is there for the
> trasformation...can u clear the idea..of where does the importance of
> DOM and SAX comes in...
> 2.are DOM and SAX interfaces..to access XML document...or DOM and SAX
> XML parsers..can u clear the idea?
SAX and DOM are interfaces to an XML document of interest primarily to
programmers and scripters. A parser generally will be of two kinds,
either a SAX parser or a DOM parser. A SAX parser reports back to the
application a stream of events encountered while reading the XML
document start to finish ("Element A begins... Element B begins... text
'xyz' found... Element B ends... Element A ends..." -- like that).
A DOM parser doesn't report these events as they "happen" (although at
some level it still has to recognize they've occurred); rather, it
returns to the application a tree of nodes built from the document.
SAX parsers tend to be very fast, but they're also somewhat, well,
low-level. (SAX is to DOM what assembly language is to a higher-level
language, I guess you could say.) Unless you're actually coding an XML
application yourself, you'll probably not want to use a SAX parser. The
DOM is much easier to use ("Get me this node's contents... now this
one's...," and so on). The downside of using the DOM is that if a
document is very large, it can be extremely memory-intensive, since
pretty much the whole tree needs to be accessible all at once.
An XSLT processor is an application which uses a parser to access a
source document and an XSLT stylesheet. If you use XSLT, you choose the
processor that fits your needs (e.g. server- vs. client-side) and don't
worry about the parser. The XSLT processor's developer(s) will have
already made that decision for you. On the other hand, some XSLT
processors allow you to swap parsers (and some don't :).
Does that help?
John E. Simpson | "I had a friend who was a clown. When
http://www.flixml.org | he died, all his friends went to the
XML Q&A: www.xml.com | funeral in one car." (Steven Wright)