Web / Apache Axiom Interview questions
What is OMDocument in Axiom?
OMDocument represents the whole XML document as parsed by a builder - it's the container above the root element, roughly analogous to DOM's Document object.
It exposes document-level information such as the XML declaration's version and character encoding, and gives access to the actual root element through getOMDocumentElement().
You typically get one from a builder, e.g. StAXOMBuilder.getDocument(), when you're parsing a complete standalone document; if you're only constructing an XML fragment by hand through OMFactory to embed elsewhere - say, as a SOAP body's payload - you often never need an OMDocument at all, since a fragment isn't a full document with its own declaration.
In practice, most day-to-day Axiom code works directly with the root OMElement rather than the surrounding OMDocument, since the element is what actually needs to be read, mutated, or serialized.
More Related questions...