Hi Doug: please can you provide me with an answer for 4.1 below. How would you stop a traversal in DJ? -- Karl ----------------- Question 4: ===================== 30 points The following is from XML for Java Compatibility API 2.0.15. http://falconet.inria.fr/~java/classes/xml4j/TXapiDocs/ It is NOT expected that you have seen those pages. I show you pieces of the documentation and ask you to interpret it based on your knowledge of traversal/visitor programming. Consider the following example of XML4J (XML for Java) code: ---- PrintWriter printWriter = new PrintWriter(); Visitor htmlPrintVisitor = new HTMLPrintVisitor(printWriter); TreeTraversal treeTraversal = new RecursivePreorderTreeTraversal(htmlPrintVisitor); treeTraversal.traverse(document); printWriter.close(); Documentation: public class RecursivePreorderTreeTraversal extends TreeTraversal RecursivePreorderTreeTraversal defines a specific document object tree traversal algorithm for use by the visitor design pattern. This algorithm visits the Parent before visiting its children. Documentation: public class HTMLPrintVisitor extends ToXMLStringVisitor HTMLPrintVisitor implements the Visitor interface in the visitor design pattern for the purpose of printing in HTML-like format the various DOM- and XML4J-defined Nodes. ---- Question 4.1: 15 points What is your interpretation of the behavior of this code? Give a brief explanation in English. Write a DJ program that has a similar behavior. Assume that you are given HTMLPrintVisitor. Consider the following documentation of EndTraversalException: public class EndTraversalException extends TreeTraversalException ---- XML4J tree traversal exception which signals from a Visitor to the tree traversal algorithm that all further traversal should be ended because the visit on the document object hierarchy has been successfully completed. For example, this exception could be used by search Visitors that are looking for the first TXElement Node which contains certain state data. ---- Question 4.2: 15 points How could EndTraversalException be added to DJ? Give a brief discussion of the interesting issues.