List of usage examples for javax.xml.stream XMLInputFactory newInstance
public static XMLInputFactory newInstance() throws FactoryConfigurationError
From source file:jodtemplate.pptx.io.PPTXReaderImpl.java
@Override public Presentation read(final Resources resources) throws IOException, XMLStreamException { final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); ContentTypes contentTypes = new ContentTypes(); contentTypes = contentTypesReader.read("/[Content_Types].xml", resources, xmlInputFactory, contentTypes); final String presentationXmlPath = contentTypes.getOverridesByType(ContentTypes.PRESENTATION_TYPE).get(0) .getPartName();/* www. j ava 2 s. c o m*/ Presentation presentation = new Presentation(presentationXmlPath); presentation = presentationXmlRelsReader.read(presentation.getXmlRelsPath(), resources, xmlInputFactory, presentation); for (Slide slide : presentation.getSlides()) { final String slideXmlPath = FilenameUtils .normalize(presentation.getFullPath() + slide.getRelationship().getTarget(), true); final String slideXmlRelsPath = Utils.getRelsPath(slideXmlPath); slideXmlRelsReader.read(slideXmlRelsPath, resources, xmlInputFactory, slide); } imageReader.read(resources, presentation); return presentation; }
From source file:edu.harvard.i2b2.fr.delegate.pm.PMServiceDriver.java
/** * Function to convert pm requestVdo to OMElement * //w w w .j a v a 2 s . c o m * @param requestPm String request to send to pm web service * @return An OMElement containing the pm web service requestVdo */ public OMElement getPmPayLoad(String requestPm) throws I2B2Exception { OMElement method = null; try { 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(requestPm); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); method = builder.getDocumentElement(); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new I2B2Exception("", e.getException()); } catch (XMLStreamException e) { log.error(e.getMessage()); throw new I2B2Exception("", e); } return method; }
From source file:com.hazelcast.simulator.probes.probes.ProbesResultXmlReader.java
public static Map<String, Result> read(InputStream inputStream) { Map<String, Result> result = new HashMap<String, Result>(); XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); try {/*ww w . j a va 2 s .co m*/ XMLEventReader reader = xmlInputFactory.createXMLEventReader(inputStream); while (reader.hasNext()) { XMLEvent event = reader.nextEvent(); if (event.isStartElement()) { StartElement startElement = event.asStartElement(); if (PROBES_RESULT.matches(startElement.getName().getLocalPart())) { parseProbesResult(reader, result); } } } } catch (XMLStreamException e) { e.printStackTrace(); } return result; }
From source file:com.sazneo.export.file.FileProcessor.java
/** * Process the XML file/*from w w w.jav a 2s . c o m*/ */ public void process() { try { Reader reader = new FileReader(exportFile); XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); XMLStreamReader xmlStreamReader = xmlFactory.createXMLStreamReader(reader); boolean fileTag = false; String fileName = null; Integer fileSize = null; while (xmlStreamReader.hasNext()) { xmlStreamReader.next(); if (xmlStreamReader.getEventType() == XMLStreamReader.START_ELEMENT) { if ("file".equals(xmlStreamReader.getLocalName())) { fileTag = true; fileName = MessageFormat.format("{0}_{1}", xmlStreamReader.getAttributeValue(null, "id"), xmlStreamReader.getAttributeValue(null, "filename")); fileSize = Integer.parseInt(xmlStreamReader.getAttributeValue(null, "size")); logger.debug(MessageFormat.format("XML contains file with name: {0} and size {1} bytes", fileName, fileSize)); } } if (fileTag) { if (xmlStreamReader.getEventType() == XMLStreamReader.CHARACTERS) { exportFile(xmlStreamReader.getText(), fileName, fileSize); } if (xmlStreamReader.getEventType() == XMLStreamReader.END_ELEMENT) { fileSize = null; fileName = null; fileTag = false; } } } } catch (FileNotFoundException e) { logger.error(MessageFormat.format("Could not find export file:-\n{0}", e)); } catch (XMLStreamException e) { logger.error(MessageFormat.format("Could not parse xml export file:-\n{0}", e)); } }
From source file:microsoft.exchange.webservices.data.security.SafeXmlDocument.java
public SafeXmlDocument() { super(); inputFactory = XMLInputFactory.newInstance(); }
From source file:com.microfocus.application.automation.tools.octane.tests.TestResultIterator.java
public TestResultIterator(Reader input) throws XMLStreamException { this.input = input; reader = XMLInputFactory.newInstance().createXMLEventReader(input); }
From source file:com.marklogic.contentpump.CompressedAggXMLReader.java
@Override public void initialize(InputSplit inSplit, TaskAttemptContext context) throws IOException, InterruptedException { initConfig(context);//from www . j a v a 2 s.co m initAggConf(context); f = XMLInputFactory.newInstance(); setFile(((FileSplit) inSplit).getPath()); fs = file.getFileSystem(context.getConfiguration()); FileStatus status = fs.getFileStatus(file); if (status.isDirectory()) { iterator = new FileIterator((FileSplit) inSplit, context); inSplit = iterator.next(); } initStreamReader(inSplit); }
From source file:edu.harvard.i2b2.crc.loader.delegate.pm.PMServiceDriver.java
/** * Function to convert pm requestVdo to OMElement * //from www.j ava 2s. co m * @param requestPm * String request to send to pm web service * @return An OMElement containing the pm web service requestVdo */ public OMElement getPmPayLoad(String requestPm) throws I2B2Exception { OMElement method = null; try { 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(requestPm); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); method = builder.getDocumentElement(); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new I2B2Exception("", e.getException()); } catch (XMLStreamException e) { log.error(e.getMessage()); throw new I2B2Exception("", e); } return method; }
From source file:it.iit.genomics.cru.structures.bridges.eppic.client.EppicJaxbClient.java
private EppicAnalysisList getPdbInterfaces(String fileName) { try {/*ww w .jav a 2 s . c o m*/ XMLInputFactory xmlif = XMLInputFactory.newInstance(); XMLStreamReader xmler = xmlif.createXMLStreamReader(new FileReader(fileName)); JAXBContext jaxbContext = JAXBContext.newInstance(EppicAnalysisList.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); EppicAnalysisList result; result = (EppicAnalysisList) jaxbUnmarshaller.unmarshal(xmler); return result; } catch (JAXBException | IOException | XMLStreamException e) { logger.error(null, e); } return null; }
From source file:com.predic8.membrane.core.multipart.XOPReconstitutor.java
public XOPReconstitutor() { xmlInputFactory = XMLInputFactory.newInstance(); xmlInputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); }