I am working with jQuery like elements from the cheerio library to manipulate SVG images.
These objects represent XML nodes and have a hierarchical internal structure.
Along the way, the function keeps track of all transform operations that have been specified upto that node, so that when it generates the point set for a shape, it will apply the accumulated scale, rotate, translate etc operations for that node.
The user supplied function will do things like generate polygon objects or calculate bounding boxes.
Is there a standard design pattern for this kind of function? It seems vaguely like a Visitor pattern but in that case the nodes would have a Visitor interface and invoke an operation themselves. I don't want to modify the cheerio objects. Furthermore, the nodes don't know where they are in the tree and cannot supply their transformation context.
This is not a difficult routine to write but I am interested to know if there is any formal theory that's relevant?