Web / Apache Axiom Interview questions
What is the difference between OMElement and OMNode?
OMNode is the base interface for anything that can occupy a slot in Axiom's tree - elements, text, comments, processing instructions, and document type declarations all implement it, giving them shared behavior like detach(), getParent(), and getNextOMSibling().
| OMNode | OMElement |
| Base type for any tree member | Extends OMNode; specific to elements |
| No concept of attributes or a tag name | Has a QName, attributes, and namespace |
| Cannot have its own child elements as such | Can contain children (elements, text, etc.) |
| Implemented by OMText, OMComment, etc. too | Implemented only by element-representing classes |
Practically, this means code that only needs to walk siblings or detach nodes generically can work against OMNode, while code that needs to read attributes, resolve namespaces, or navigate to specific child elements by name needs the richer OMElement interface specifically.
More Related questions...