Q. How to traverse tree if processor receive data by querying XML storage one element at a time.
A. Reintroduce stack-discipline and use recursive algorithm as usually.
Stack need to store only variables which `recursive algorithm would use. In case of XML traverse it is
tuple of (parentIndex, childName, childIndex) which defines any XML node uniquely.
foldActor () {
stack.pop(parentIndex, childName, childIndex) // restore stack
do stuff
push((parentIndex, childName, childIndex)) // push recurse step
}
No comments:
Post a Comment