Can I achieve conversion of XML from one format to another using a SAX parser or a Transformer? If so, then what is the exact difference ?
EDIT:: I mean the transformer I create using SAXTransformerFactory
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The SAX parser allows you to parse the XML document within Java. It will call you back for every element, character sequence etc. and using this you can construct a object tree representing some/all of the XML, or perform some other function.
Other types of parsers exist. A DOM parser will give you a tree-based object representation of the XML document. THere are pros/cons to each parser type (DOM is typically characterised as more-memory intensive, but providing a complete model of the XML, whereas SAX is lightweight but you’re called back by the parser itself and can’t navigate any model of the XML)
I’m a little vague wrt. your XML Transformer, but I assume you mean an XSLT. That’s a stylesheet transformation, and operates at a higher level, applying a transformation (stylesheet) to the input XML and giving an output (usually, but not limited to, XML)
EDIT: Following your comment, see this article: