/** * Create an object model builder that reads an XML document from the provided character stream * using a specified object model factory and with a given parser configuration. * * @param omFactory * the object model factory to use * @param configuration * the parser configuration to use * @param in * the character stream representing the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, StAXParserConfiguration configuration, Reader in) { return omFactory.getMetaFactory().createOMBuilder(omFactory, configuration, new InputSource(in)); }
/** * 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); }
/** * Create an object model builder that reads an XML document from the provided {@link Source} * using a specified object model factory. When used with a {@link DOMSource} or * {@link SAXSource}, entities are expanded, i.e. the method has the same behavior as * {@link #createOMBuilder(OMFactory, Node, boolean)} and * {@link #createOMBuilder(OMFactory, SAXSource, boolean)} with {@code expandEntityReferences} * set to {@code true}. * * @param omFactory * the object model factory to use * @param source * the source of the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, Source source) { return omFactory.getMetaFactory().createOMBuilder(omFactory, source); }
/** * Create an object model builder that reads an XML document from the provided input stream * using a specified object model factory and with a given parser configuration. * * @param omFactory * the object model factory to use * @param configuration * the parser configuration to use * @param in * the input stream representing the XML document * @param encoding * the charset encoding of the XML document or <code>null</code> if the parser should * determine the charset encoding * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, StAXParserConfiguration configuration, InputStream in, String encoding) { InputSource is = new InputSource(in); is.setEncoding(encoding); return omFactory.getMetaFactory().createOMBuilder(omFactory, configuration, is); }
/** * Create an object model builder that reads an XML document from the provided DOM tree using a * specified object model factory. * * @param omFactory * the object model factory to use * @param node * the DOM node; must be a {@link Node#DOCUMENT_NODE} or {@link Node#ELEMENT_NODE} * @param expandEntityReferences * Determines how {@link EntityReference} nodes are handled: * <ul> * <li>If the parameter is <code>false</code> then a single {@link OMEntityReference} * will be created for each {@link EntityReference}. The child nodes of * {@link EntityReference} nodes are not taken into account. * <li>If the parameter is <code>true</code> then no {@link OMEntityReference} nodes * are created and the children of {@link EntityReference} nodes are converted and * inserted into the Axiom tree. * </ul> * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, Node node, boolean expandEntityReferences) { return omFactory.getMetaFactory().createOMBuilder(omFactory, node, expandEntityReferences); }
/** * Create an object model builder that reads an XML document from the provided {@link SAXSource} * using a specified object model factory. * * @param omFactory * the object model factory to use * @param source * the source of the XML document * @param expandEntityReferences * Determines how entity references (i.e. {@link LexicalHandler#startEntity(String)} * and {@link LexicalHandler#endEntity(String)} events) are handled: * <ul> * <li>If the parameter is <code>false</code> then a single {@link OMEntityReference} * will be created for each pair of {@link LexicalHandler#startEntity(String)} and * {@link LexicalHandler#endEntity(String)} events. Other events reported between * these two events are not taken into account. * <li>If the parameter is <code>true</code> then no {@link OMEntityReference} nodes * are created and {@link LexicalHandler#startEntity(String)} and * {@link LexicalHandler#endEntity(String)} events are ignored. However, events * between {@link LexicalHandler#startEntity(String)} and * {@link LexicalHandler#endEntity(String)} are processed normally. * </ul> * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, SAXSource source, boolean expandEntityReferences) { return omFactory.getMetaFactory().createOMBuilder(omFactory, source, expandEntityReferences); }
/** * 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; } }
public void setContent(Source source) throws SOAPException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader reader; if (source instanceof StreamSource) { reader = inputFactory.createXMLStreamReader(source); } else { Result result = new StreamResult(baos); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); InputStream is = new ByteArrayInputStream(baos.toByteArray()); reader = inputFactory.createXMLStreamReader(is); } SOAPModelBuilder builder1 = OMXMLBuilderFactory.createStAXSOAPModelBuilder( envelope.omTarget.getOMFactory().getMetaFactory(), reader); envelope = new SOAPEnvelopeImpl(builder1.getSOAPEnvelope()); envelope.omTarget.build(); this.document = envelope.getOwnerDocument(); envelope.setSOAPPartParent(this); } catch (TransformerFactoryConfigurationError e) { log.error(e); throw new SOAPException(e); } catch (Exception e) { log.error(e); throw new SOAPException(e); } }
/** * In Axiom, a single tree should always contain objects created from the same type of factory * (eg: LinkedListImplFactory, DOMFactory, etc.,). This method will convert omAttribute to the * given omFactory. * * @see ElementHelper#importOMElement(OMElement, OMFactory) to convert instances of OMElement */ public static void importOMAttribute(OMAttribute omAttribute, OMElement omElement) { // first check whether the given OMAttribute has the same OMFactory if (omAttribute.getOMFactory().getMetaFactory() == omElement.getOMFactory().getMetaFactory()) { omElement.addAttribute(omAttribute); } else { OMNamespace ns = omAttribute.getNamespace(); omElement.addAttribute(omAttribute.getLocalName(), omAttribute.getAttributeValue(), omElement.getOMFactory().createOMNamespace(ns.getNamespaceURI(), ns.getPrefix())); } } }
if (env.getOMFactory().getMetaFactory() == OMAbstractFactory.getMetaFactory()) { return env;
/** * Create an XOP aware model builder from the provided {@link Attachments} object using a * specified object model factory and with a given parser configuration. * * @param omFactory * the object model factory to use * @param configuration * the parser configuration to use * @param attachments * an {@link Attachments} object that must have been created from an input stream * @return the builder * @throws OMException * if an error occurs while processing the content type information from the * {@link Attachments} object */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, StAXParserConfiguration configuration, Attachments attachments) { ContentType contentType; try { contentType = new ContentType(attachments.getRootPartContentType()); } catch (ParseException ex) { throw new OMException(ex); } InputSource rootPart = getRootPartInputSource(attachments, contentType); return omFactory.getMetaFactory().createOMBuilder(configuration, omFactory, rootPart, new AttachmentsMimePartProvider(attachments)); }
try { OMElement subscriptionManagerElement = EndpointReferenceHelper.toOM( subscribeResponseElement.getOMFactory().getMetaFactory().getOMFactory(), subscriptionManagerEPR, new QName(EventingConstants.WSE_EVENTING_NS,
if (omNode.getOMFactory().getMetaFactory() == container.getOMFactory().getMetaFactory()) { child = (OMNodeEx)omNode; } else {