/** * Create an object model builder that pulls events from a StAX stream reader using a specified * object model factory. * <p> * See {@link #createStAXOMBuilder(XMLStreamReader)} for more information about the behavior of * the returned builder. * * @param omFactory * the object model factory to use * @param parser * the stream reader to read the XML data from * @return the builder */ public static OMXMLParserWrapper createStAXOMBuilder(OMFactory omFactory, XMLStreamReader parser) { return omFactory.getMetaFactory().createStAXOMBuilder(omFactory, parser); }
return metaFactory.createStAXOMBuilder(metaFactory.getOMFactory(), parser);
/** * Some times two OMElements needs to be added to the same object tree. But in Axiom, a single * tree should always contain object created from the same type of factory (eg: * LinkedListImplFactory, DOMFactory, etc.,). If one OMElement is created from a different * factory than that of the factory which was used to create the object in the existing tree, we * need to convert the new OMElement to match to the factory of existing object tree. This * method will convert omElement to the given omFactory. * * @see AttributeHelper#importOMAttribute(OMAttribute, OMElement) to convert instances of * OMAttribute */ public static OMElement importOMElement(OMElement omElement, OMFactory omFactory) { // first check whether the given OMElement has the same omFactory if (omElement.getOMFactory().getMetaFactory() == omFactory.getMetaFactory()) { return omElement; } else { OMElement documentElement = omFactory.getMetaFactory().createStAXOMBuilder( omFactory, omElement.getXMLStreamReader()).getDocumentElement(); documentElement.build(); return documentElement; } }