January 2017
Intermediate to advanced
314 pages
6h 42m
English
The tree-structured DOM created by us needs to be traversed to produce the content in an output format like HTML, PDF, or SVG.
The composite tree created by us can be traversed using the GoF visitor pattern. Wherever composite pattern is used for composing an hierarchy of objects, the visitor pattern is a natural choice for the traversal of the tree.
In a visitor pattern implementation, every node in the composite tree will support a method called accept, which takes a visitor concrete class as a parameter. The job of the accept routine is to reflect the call to the appropriate visit method in the visitor concrete class. We declare an interface named IDocumentVisitor with methods for visiting each of the ...
Read now
Unlock full access