Web / Apache Axiom Interview questions
Define deferred building (lazy building) in Axiom?
Deferred building, also called lazy building, is Axiom's core design principle: instead of parsing an entire XML document into objects up front, Axiom only materializes the portion of the tree that the application actually navigates to.
Under the hood, a builder (typically StAXOMBuilder) wraps a StAX XMLStreamReader. As code calls navigation methods like getNextOMSibling() or getFirstElement(), the builder pulls the next event(s) from the underlying parser on demand and converts them into OM nodes, appending them to the tree as it goes.
Parts of the document that are never navigated - for example, a large payload an intermediary never inspects - are simply never converted into objects at all, which is where the memory and CPU savings come from compared to an eagerly-built model like DOM.
You can always force full materialization of an element and its descendants by calling build() on it, which keeps pulling events until that subtree is complete.
More Related questions...