@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } try { if (logger.isInfoEnabled()) logger.info("Parsing StAX stream from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLStreamReader(content, "UTF-8"); } catch (XMLStreamException e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } } @Override
@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } try { if (logger.isInfoEnabled()) logger.info("Parsing StAX stream from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLStreamReader(content, "UTF-8"); this.contentSource = content; } catch (XMLStreamException e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } } @Override
@Override public void write(OutputStream out) throws IOException { try { XMLInputFactory inputFactory = getFactory(); if (inputFactory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } // TODO: rework to copy straight from stream reader to stream writer XMLEventReader reader = inputFactory.createXMLEventReader(content); XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); XMLEventWriter writer = outputFactory.createXMLEventWriter(out, "UTF-8"); writer.add(reader); writer.flush(); writer.close(); content.close(); } catch (XMLStreamException e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } } }
@Override public void write(OutputStream out) throws IOException { try { XMLInputFactory inputFactory = getFactory(); if (inputFactory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } // TODO: rework to copy straight from stream reader to stream writer XMLEventReader reader = inputFactory.createXMLEventReader(content); XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); XMLEventWriter writer = outputFactory.createXMLEventWriter(out, "UTF-8"); writer.add(reader); writer.flush(); writer.close(); content.close(); } catch (XMLStreamException e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } } }
streamHandle.getFactory().createXMLStreamReader( new StringReader(docIn)