Since I am writing this Bio by myself I won't writing it in 3rd Person. The motivation to post here is to get feedback of my post's, which are mostly summary of mine about software development. Other reason to write here is to share my experience with the community. That all together as résumé I would give a name like "The Philosophy of Programming" or in other words "Bullshit Bingo for Coders". Kosta has posted 12 posts at DZone. You can read more from them at their website. View Full User Profile

Java and XML - Part 1

09.07.2013
| 4757 views |
  • submit to reddit

This is another article about Java and XML in general with some links to other articles. Also I added some terms to explanation what all the abbreviation stands for.  

For all readers which do not know what Java and XML is here are some wikipedia links: 


When using Java as programming language in your application you will sometimes be confronted with the need to work with XML, such parsing or writing data. For those purposes there are two Java APIs available: JAXP and JAXB


JAXP - Java API for XML Processing


The API which is used to manipulate XML files via Java is called Java API for XML Processing (JAXP ).

There are three different processing methods for manipulating the XML files via JAXP:
  • DOM (Document Object Model) 
  • SAX (Simple API for XML) 
  • StAX (Streaming API for XML) 
For better understanding of the three interfaces and methods I can recommend you read the DZone Refcard (requires registration) on Using XML with Java ,or this useful article  where all 3 interfaces are described very well.
  
From the implementation description from the given sources above you can see that the SAX method of parsing is the most boxed, and I think the least used method for manipulating XML via Java. (Correct me if I am wrong.)  

Several weeks ago, I saw that J2EE 7 has a JSON API with a DOM-like implementation, where JSON Objects are used, and the StAX method, where an iterator iterate through the JSON Stream/File. Maybe that is some kind of proof that the SAX parsing method is the most unused method and as such, wasn't implemented for the manipulation of JSON files.

Besides these three implementations in Java SE there are others XML parsers which are not part of the Java core API.

Next Step / Article: I would like to write something about the JDOM2 and the W3C DOM parser. Also the usage of XPath will take a part in the explanation of the parser descriptions.
Next Step / Article: XSLT will be another theme that should be mentioned here.

Oracle Links:


JAXB - Java Architecture for XML Binding


Other way to read the data from XML file or to write Java data to a XML file is to bind them to Java object via the JAXB  API.

The main two terms used for this kind of processing are:
  • Marshalling - the process when data from Java objects are written into XML.
  • Unmarshalling - the process when XML data is transformed into Java objects.  

Next Step / Article: In an extra article I will write about JAXB usage, including the most used annotations and adding some links where I have got my information from.

Oracle Links:
Published at DZone with permission of its author, Kosta Stojanovski.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)