Web / Apache Axiom Interview questions
What is OMFactory used for?
OMFactory is Axiom's factory interface for creating OM tree nodes programmatically, rather than obtaining them by parsing existing XML - it's the tool you reach for when your application is generating XML from scratch.
You obtain an instance via OMAbstractFactory.getOMFactory() for plain XML, or getSOAP11Factory()/getSOAP12Factory() when the content specifically needs to be SOAP-correct.
OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://example.com/ns", "ex"); OMElement root = factory.createOMElement("Order", ns); OMElement id = factory.createOMElement("Id", ns); id.setText("12345"); root.addChild(id);
Every element, attribute, text node, comment, and processing instruction that isn't the direct product of parsing ultimately gets created through one of OMFactory's createOMxxx methods.
More Related questions...