(C) 2011 — Software Languages Team, University of Koblenz-Landau
Navigation
Check-in deadline
May 6, 2011 (End Of Day, Koblenz timezone)
Pointers
- http://101companies.uni-koblenz.de/index.php/101implementation:dom
- http://101companies.uni-koblenz.de/index.php/101implementation:sax
Variation 1
Title
SAX-based DOM de-serializer
Instructions
Define a SAX handler that constructs a DOM tree. Hint/Explanation: This is actually what happens anyhow when you load an XML file with the DOM API, but you are required to discover this piece of code yourself. You need to figure out how to construct DOM trees in the first place. Essentially, this works by using a Document instance as a factory for Element and Text instances. Once you understand construction by itself, you need to set up the SAX handler so that it invokes the methods for DOM construction in the right order. The use of SAX is straightforward; you do not need to go beyond what has been demonstrated in the lecture. Simplification: Use a simple XML subset of your choice. For instance, you do not need to bother about XML namespaces. You can also ignore XML attributes if you like. Overall, you need to do some research (with Bing, Google, etc.) to identify the right API-usage patterns for DOM.
Variation 2
Title
XMLStreamWriter-based DOM serializer
Instructions
Define a tree walker for the serialization of a DOM tree. Hint/Explanation: This is actually what happens anyhow when you save an XML file with the DOM API, but you are required to discover this piece of code yourself. You need to figure out how to walk DOM trees in the first place. Essentially, you need to use some query axes of DOM to discover the name of a given element and to list all children node which are then to be handled one by one. Once you understand walking by itself, you need to attach simple actions to the walker so that an output file is produced with the help of XMLStreamWriter API (which was demonstrated with the SAX-based implementation of "cut" in the lecture). Simplification: Use a simple XML subset of your choice. For instance, you do not need to bother about XML namespaces. You can also ignore XML attributes if you like. Overall, you need to do some research (with Bing, Google, etc.) to identify the right API-usage patterns for DOM.