/** * Create a SAX {@link XMLReader} that reads from the given StAX {@link XMLStreamReader}. * @param streamReader the StAX stream reader * @return a XMLReader reading from the {@code streamWriter} */ public static XMLReader createXMLReader(XMLStreamReader streamReader) { return new StaxStreamXMLReader(streamReader); }
/** * Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}. * The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or * {@code XMLStreamConstants.START_ELEMENT} state. * @param streamReader the {@code XMLStreamReader} to read from * @throws IllegalStateException if the reader is not at the start of a document or element */ StaxSource(XMLStreamReader streamReader) { super(new StaxStreamXMLReader(streamReader), new InputSource()); this.streamReader = streamReader; }
/** * Create a SAX {@link XMLReader} that reads from the given StAX {@link XMLStreamReader}. * @param streamReader the StAX stream reader * @return a XMLReader reading from the {@code streamWriter} */ public static XMLReader createXMLReader(XMLStreamReader streamReader) { return new StaxStreamXMLReader(streamReader); }
/** * Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}. * The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or * {@code XMLStreamConstants.START_ELEMENT} state. * @param streamReader the {@code XMLStreamReader} to read from * @throws IllegalStateException if the reader is not at the start of a document or element */ StaxSource(XMLStreamReader streamReader) { super(new StaxStreamXMLReader(streamReader), new InputSource()); this.streamReader = streamReader; }
@Override protected AbstractStaxXMLReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException { return new StaxStreamXMLReader(inputFactory.createXMLStreamReader(inputStream)); }
@Test public void partial() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(CONTENT)); streamReader.nextTag(); // skip to root assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "root"), streamReader.getName()); streamReader.nextTag(); // skip to child assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "child"), streamReader.getName()); StaxStreamXMLReader xmlReader = new StaxStreamXMLReader(streamReader); ContentHandler contentHandler = mock(ContentHandler.class); xmlReader.setContentHandler(contentHandler); xmlReader.parse(new InputSource()); verify(contentHandler).setDocumentLocator(any(Locator.class)); verify(contentHandler).startDocument(); verify(contentHandler).startElement(eq("http://springframework.org/spring-ws"), eq("child"), eq("child"), any(Attributes.class)); verify(contentHandler).endElement("http://springframework.org/spring-ws", "child", "child"); verify(contentHandler).endDocument(); }
/** * Create a SAX {@link XMLReader} that reads from the given StAX {@link XMLStreamReader}. * @param streamReader the StAX stream reader * @return a XMLReader reading from the <code>streamWriter</code> */ public static XMLReader createXMLReader(XMLStreamReader streamReader) { return new StaxStreamXMLReader(streamReader); }
/** * Constructs a new instance of the <code>StaxSource</code> with the specified <code>XMLStreamReader</code>. The * supplied stream reader must be in <code>XMLStreamConstants.START_DOCUMENT</code> or * <code>XMLStreamConstants.START_ELEMENT</code> state. * * @param streamReader the <code>XMLStreamReader</code> to read from * @throws IllegalStateException if the reader is not at the start of a document or element */ StaxSource(XMLStreamReader streamReader) { super(new StaxStreamXMLReader(streamReader), new InputSource()); this.streamReader = streamReader; }
/** * Create a SAX {@link XMLReader} that reads from the given StAX {@link XMLStreamReader}. * @param streamReader the StAX stream reader * @return a XMLReader reading from the {@code streamWriter} */ public static XMLReader createXMLReader(XMLStreamReader streamReader) { return new StaxStreamXMLReader(streamReader); }
/** * Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}. * The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or * {@code XMLStreamConstants.START_ELEMENT} state. * @param streamReader the {@code XMLStreamReader} to read from * @throws IllegalStateException if the reader is not at the start of a document or element */ StaxSource(XMLStreamReader streamReader) { super(new StaxStreamXMLReader(streamReader), new InputSource()); this.streamReader = streamReader; }
/** * Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}. * The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or * {@code XMLStreamConstants.START_ELEMENT} state. * @param streamReader the {@code XMLStreamReader} to read from * @throws IllegalStateException if the reader is not at the start of a document or element */ StaxSource(XMLStreamReader streamReader) { super(new StaxStreamXMLReader(streamReader), new InputSource()); this.streamReader = streamReader; }
return new StaxStreamXMLReader(streamReader);