How to generate Axiom OMElement Using input Stream

The method showed below is generate   Axiom OMElement  from input stream
  
   /**
     * @param inputStream Reads input stream that use to build OMElement
     * @return  OMElement that generated from input stream
     * @throws Exception at error in generating parser
     */
    public static OMElement buildOMElement(InputStream inputStream) throws Exception {
        XMLStreamReader parser;
        try {
            parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
        }
        catch (XMLStreamException e) {
            String msg = "Error in initializing the parser to build the OMElement.";
            log.error(msg, e);
            throw new Exception(msg, e);
        }
        finally {
           log.info("Reading data from configuration file");
        }
        StAXOMBuilder builder = new StAXOMBuilder(parser);
        return builder.getDocumentElement();
    }


we can call this method as follows

OMElement  element=buildOMElement(new FileInputStream("File path String"));

If you need more information go to this link

1 comment:

  1. These are really great ideas in on the topic of blogging.
    You have touched some nice things here. Any way keep up wrinting.
    Take a look at my web page :: Phone Therapy

    ReplyDelete

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...