While using recursion is an easy way of generating XML it can lead to the call stack overflowing when serialising documents with lots of nested nodes. Generally there are two ways of working around this: 1. Use an explicit stack (e.g. an array or a queue of sorts) instead of relying on the call stack. 2. Use an algorithm that doesn't use a stack at all (e.g. Morris traversal). This commit introduces the XML::Generator class which can serialize documents back to XML without using a stack at all. This class takes advantage of XML nodes having access to not only their child nodes, but also their siblings and their parents. All XML serialisation logic now resides in the XML::Generator class. In turn the various "to_xml" methods just use this class and serialize everything starting at "self". |
||
|---|---|---|
| .. | ||
| oga | ||
| support | ||
| spec_helper.rb | ||