wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Difference between a parser and xsl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Difference between a parser and xsl" Watch "Difference between a parser and xsl" New topic
Author

Difference between a parser and xsl

Ram Korutla
Ranch Hand

Joined: Dec 24, 2007
Posts: 80
Hi All
I am a bit new to the xml technologies.

I dont understand why an xsl should be required if we could access the nodes and the other xml related stuff using the parsers.

Please correct my below understanding:

An xsl can access and apply certain rules to the elements of xml without however actually modifying the content of the xml. With parsers we can actually add or delete the nodes of an xml.

Kindly let me know what exactly parsers and xsls are used for.

Many Thanks
Phani
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

In theory, yes, anything you can do with XSL, you can do by programming in Java using the DOM tree produced by an XML parser. In theory, you don't need the parser, either; you could read the XML with a FileReader and pick through it yourself. Heck, you don't even need Java, do you: you could write the same program in 80x86 assembly language.

My point is that different tools operate at different levels, and have different strengths. Many simple querying and transformation tasks are clearer and easier to write in XSL.


[Jess in Action][AskingGoodQuestions]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Phani Sridhar:
With parsers we can actually add or delete the nodes of an xml.
Well, no, this is incorrect. The purpose of a parser is to convert an XML document -- a text file, usually -- into some internal form. A DOM parser converts a document into a Document object, a SAX parser converts it into a series of SAX events, and so on. No adding or deleting of nodes will occur here.

You can certainly take the Document object which is the output of the parser and add or delete nodes, though.

And just for completeness: a serializer is used to convert some internal form into an XML document.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between a parser and xsl
 
Similar Threads
Transforming Huge xml about 50 MB in size
javascript vs java XML parsers
XML DOM
How to start learning XML, XSL, DOM and SAX?
XPath Technology