Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1141
  • Last Modified:

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.
0
letsbedecent
Asked:
letsbedecent
  • 4
  • 2
  • 2
  • +3
1 Solution
 
kupra1Commented:
0
 
sudhakar_koundinyaCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
letsbedecentAuthor Commented:
any partcular situations where this might be usefull over DOM Source ??
0
 
dream2k5Commented:
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
 
NaeemgCommented:
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
 
sanjuskCommented:
0
 
sanjuskCommented:
forget to mention the link i posted consider all aspect and explain using example
0
 
sudhakar_koundinyaCommented:
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
 
sudhakar_koundinyaCommented:
>>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
 
sudhakar_koundinyaCommented:
And also you should see this link
http://xml.apache.org/xalan-j/dtm.html

Regards
Sudhakar
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now