List of usage examples for javax.xml.stream XMLInputFactory createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(java.io.InputStream stream) throws XMLStreamException;
From source file:edu.harvard.i2b2.pm.ws.MessageFactory.java
/** * Function creates PFT response OMElement from xml string * @param xmlString// www . j a v a2 s.co m * @return OMElement * @throws XMLStreamException */ public static OMElement createResponseOMElementFromString(String xmlString) throws XMLStreamException { OMElement returnElement = null; try { StringReader strReader = new StringReader(xmlString); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); returnElement = builder.getDocumentElement(); } catch (XMLStreamException xmlStreamEx) { log.error("Error while converting PM response ConfigureType to OMElement"); throw xmlStreamEx; } return returnElement; }
From source file:edu.harvard.i2b2.eclipse.login.LoginHelper.java
/** * Function to convert pm request to OMElement * //from w w w . j a va2 s.c om * @param requestVdo String request to send to pm web service * @return An OMElement containing the pm web service request */ public static OMElement getPmPayLoad(String requestVdo) throws Exception { OMElement method = null; try { StringReader strReader = new StringReader(requestVdo); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); method = builder.getDocumentElement(); /* OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://www.i2b2.org/xsd/hive/msg", "i2b2"); method = fac.createOMElement("request", omNs); StringReader strReader = new StringReader(requestVdo); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); //method = builder.getDocumentElement(); OMElement lineItem = builder.getDocumentElement(); method.addChild(lineItem); */ } catch (FactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); log.error(e.getMessage()); throw new Exception(e); } return method; }
From source file:edu.harvard.i2b2.im.ws.MessageFactory.java
/** * Function creates Workplace response OMElement from xml string * @param xmlString//from w w w.j a va 2 s . com * @return OMElement * @throws XMLStreamException */ public static OMElement createResponseOMElementFromString(String xmlString) throws I2B2Exception { OMElement returnElement = null; try { StringReader strReader = new StringReader(xmlString); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); returnElement = builder.getDocumentElement(); } catch (XMLStreamException e) { log.error("xml stream response WDO to OMElement"); throw new I2B2Exception("XML Stream error ", e); } catch (Exception e) { log.error("Error while converting IM response WDO to OMElement"); throw new I2B2Exception("Response OMElement creation error ", e); } return returnElement; }
From source file:edu.harvard.i2b2.ontology.ws.MessageFactory.java
/** * Function creates Ontology response OMElement from xml string * /* ww w .j av a 2s . c o m*/ * @param xmlString * @return OMElement * @throws XMLStreamException */ public static OMElement createResponseOMElementFromString(String xmlString) throws I2B2Exception { OMElement returnElement = null; try { StringReader strReader = new StringReader(xmlString); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); returnElement = builder.getDocumentElement(); } catch (XMLStreamException e) { log.error("Error while converting Ontology response VDO to OMElement"); throw new I2B2Exception("XML Stream error ", e); } return returnElement; }
From source file:io.cloudslang.content.xml.utils.XmlUtils.java
/** * Returns the Namespaces context from an xml. * * @param xmlString xml as string//ww w . j a va2 s . co m * @param xmlFilePath path to xml file * @return the Namespaces context from an xml. * @throws IOException file reading exception * @throws XMLStreamException parsing exception */ public static NamespaceContext getNamespaceContext(String xmlString, String xmlFilePath) throws Exception { InputStream inputXML = getStream(xmlString, xmlFilePath); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader reader = inputFactory.createXMLStreamReader(inputXML); Map<String, String> namespaces = new HashMap<>(); while (reader.hasNext()) { int evt = reader.next(); if (evt == XMLStreamConstants.START_ELEMENT) { QName qName = reader.getName(); if (qName != null) { if (qName.getPrefix() != null && qName.getPrefix().compareTo("") != 0) namespaces.put(qName.getPrefix(), qName.getNamespaceURI()); } } } return new SimpleNamespaceContext(namespaces); }
From source file:edu.harvard.i2b2.eclipse.plugins.analysis.ontologyMessaging.OntServiceDriver.java
/** * Function to convert Ont requestVdo to OMElement * /*w w w .jav a2 s .co m*/ * @param requestVdo String requestVdo to send to Ont web service * @return An OMElement containing the Ont web service requestVdo */ public static OMElement getOntPayLoad(String requestVdo) throws Exception { OMElement lineItem = null; try { StringReader strReader = new StringReader(requestVdo); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); lineItem = builder.getDocumentElement(); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } return lineItem; }
From source file:edu.harvard.i2b2.crc.axis2.MessageFactory.java
/** * Function creates Workplace response OMElement from xml string * @param xmlString//from ww w . ja va2 s . c o m * @return OMElement * @throws XMLStreamException */ public static OMElement createResponseOMElementFromString(String xmlString) throws I2B2Exception { OMElement returnElement = null; try { StringReader strReader = new StringReader(xmlString); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); returnElement = builder.getDocumentElement(); } catch (XMLStreamException e) { log.error("xml stream response PDO to OMElement"); throw new I2B2Exception("XML Stream error ", e); } catch (Exception e) { log.error("Error while converting CRC response PDO to OMElement"); throw new I2B2Exception("Response OMElement creation error ", e); } return returnElement; }
From source file:edu.harvard.i2b2.eclipse.plugins.patientSet.workplaceMessaging.WorkplaceServiceDriver.java
/** * Function to convert Work requestWdo to OMElement * //from w ww. j av a 2 s . co m * @param requestWdo String requestWdo to send to Work web service * @return An OMElement containing the Work web service requestWdo */ public static OMElement getWorkPayLoad(String requestWdo) throws Exception { OMElement lineItem = null; try { StringReader strReader = new StringReader(requestWdo); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); lineItem = builder.getDocumentElement(); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } return lineItem; }
From source file:edu.harvard.i2b2.analysis.queryClient.CRCQueryClient.java
public static OMElement getQueryPayLoad(String str) throws Exception { StringReader strReader = new StringReader(str); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); OMElement lineItem = builder.getDocumentElement(); // log.debug("Line item string " + lineItem.toString()); return lineItem; }
From source file:sdmx.net.service.nomis.NOMISRESTServiceRegistry.java
public static List<NOMISGeography> parseGeography(InputStream in, String cubeId, String cubeName) throws XMLStreamException { List<NOMISGeography> geogList = new ArrayList<NOMISGeography>(); String tagContent = null;//from w w w. j a va2 s . c o m XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(in); int state = 0; String lastLang = null; while (reader.hasNext()) { int event = reader.next(); switch (event) { case XMLStreamConstants.START_ELEMENT: if (reader.getLocalName().equals("Type")) { NOMISGeography geog = new NOMISGeography(); geog.setCubeId(cubeId); geog.setCubeName(cubeName); geog.setGeography(reader.getAttributeValue("", "value")); geog.setGeographyName(reader.getAttributeValue("", "name")); geogList.add(geog); } break; case XMLStreamConstants.END_ELEMENT: break; } } return geogList; }