?
Solved

DOM Source Vs SAX Source

Posted on 2005-03-04
11
Medium Priority
?
1,065 Views
Last Modified: 2013-11-23
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.
0
Comment
Question by:letsbedecent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 10

Expert Comment

by:kupra1
ID: 13464672
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 13464822
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.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:letsbedecent
ID: 13464884
any partcular situations where this might be usefull over DOM Source ??
0
 

Expert Comment

by:dream2k5
ID: 13465691
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.
0
 
LVL 5

Expert Comment

by:Naeemg
ID: 13466256
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.
0
 
LVL 1

Expert Comment

by:sanjusk
ID: 13467454
0
 
LVL 1

Expert Comment

by:sanjusk
ID: 13467458
forget to mention the link i posted consider all aspect and explain using example
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 13476654
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
DTM.

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.



0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 13476715
>>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

Regards
Sudhakar
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 2000 total points
ID: 13477392
And also you should see this link
http://xml.apache.org/xalan-j/dtm.html

Regards
Sudhakar
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question