DOM Source Vs SAX Source

Hello ,

            I know that trasfrom method takes two inputs, sourse and result,  where source should be either a DOM Source or a SAX Source., i want to know when to use either one of these... !! i mean under which situation to use DOM or SAX sources.

           I know when to use a DOM parser and when to use a SAX parser...... but i couldnt understand when to use one of these sources.Please explain.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

By supporting a SAXSource and SAXResult, Xalan can do incremental transformations. Recall that the SAX API uses an event model to parse an XML document. These events can be acted upon and transformed as they arise.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

letsbedecentAuthor Commented:
any partcular situations where this might be usefull over DOM Source ??
If you want to modify single nodes of the XML-Tree i think DOM is better, but if you want to build an own structure from the document that is being read, SAX is the better choice. Also does DOM require more memory since it loads the whole document into memory, SAX is more "memory-friendly", so if you have large documents and not much memory you should use SAX.
SAX is used when the input xml doc is very heavy, as it is event driven .

also u can use SAX when u want ot know how many well-formdness and validation errors are in the xml doc.
forget to mention the link i posted consider all aspect and explain using example
Xalan's internal model API is DTM.

Basically xalan is providing 3 Source objects inorder to transfrom XML to other format

DOMSource is used to indicate that the DTM API should be wrapped around a
user-provided DOM.

SAXSource is used to indicate that a DTM should be built from a
user-provided stream of SAX events.

Coming to StreamSource it is stream mechanism.
As noted above, a text stream just gets parsed into a SAX stream and
treated the same thereafter.

StreamSource is used to indicate that a parser should be instantiated to
parse the user-provided text stream into a DTM; this is generally done by
using the SAXSource path internally.

XSLT includes operations which can refer back to earlier parts of the
document. That requires random access to all the document's contents, which
is generally impelemnted by building an in-memory model -- in our case, a

Theoretically it should be possible to pre-analyse the stylesheet to
recognize those stylesheets which can operate without a persistant model,
or to retain only those portions of the model which will actually be
re-examined. Please search the archives of this mailing list for the
keywords "streaming" and "pruning" to find past discussion of possible
approaches to achieving that optimization. It's a difficult problem, and
Xalan does not implement it at this time.

>>Please search the archives of this mailing list for the keywords "streaming" and "pruning" to find past discussion of possible

I mean you can search in Xalan mailing list

And also you should see this link


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.