/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLStreamReader}. * @param streamReader the StAX stream reader * @return a source wrapping the {@code streamReader} */ public static Source createCustomStaxSource(XMLStreamReader streamReader) { return new StaxSource(streamReader); }
/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLEventReader}. * @param eventReader the StAX event reader * @return a source wrapping the {@code eventReader} */ public static Source createCustomStaxSource(XMLEventReader eventReader) { return new StaxSource(eventReader); }
/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLStreamReader}. * @param streamReader the StAX stream reader * @return a source wrapping the {@code streamReader} */ public static Source createCustomStaxSource(XMLStreamReader streamReader) { return new StaxSource(streamReader); }
/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLEventReader}. * @param eventReader the StAX event reader * @return a source wrapping the {@code eventReader} */ public static Source createCustomStaxSource(XMLEventReader eventReader) { return new StaxSource(eventReader); }
@Test public void streamReaderSourceToDOMResult() throws Exception { XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(XML)); StaxSource source = new StaxSource(streamReader); assertEquals("Invalid streamReader returned", streamReader, source.getXMLStreamReader()); assertNull("EventReader returned", source.getXMLEventReader()); Document expected = documentBuilder.parse(new InputSource(new StringReader(XML))); Document result = documentBuilder.newDocument(); transformer.transform(source, new DOMResult(result)); assertThat("Invalid result", result, isSimilarTo(expected)); }
@Test public void eventReaderSourceToDOMResult() throws Exception { XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML)); StaxSource source = new StaxSource(eventReader); assertEquals("Invalid eventReader returned", eventReader, source.getXMLEventReader()); assertNull("StreamReader returned", source.getXMLStreamReader()); Document expected = documentBuilder.parse(new InputSource(new StringReader(XML))); Document result = documentBuilder.newDocument(); transformer.transform(source, new DOMResult(result)); assertThat("Invalid result", result, isSimilarTo(expected)); } }
@Test public void streamReaderSourceToStreamResult() throws Exception { XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(XML)); StaxSource source = new StaxSource(streamReader); assertEquals("Invalid streamReader returned", streamReader, source.getXMLStreamReader()); assertNull("EventReader returned", source.getXMLEventReader()); StringWriter writer = new StringWriter(); transformer.transform(source, new StreamResult(writer)); assertThat("Invalid result", writer.toString(), isSimilarTo(XML)); }
@Test public void eventReaderSourceToStreamResult() throws Exception { XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML)); StaxSource source = new StaxSource(eventReader); assertEquals("Invalid eventReader returned", eventReader, source.getXMLEventReader()); assertNull("StreamReader returned", source.getXMLStreamReader()); StringWriter writer = new StringWriter(); transformer.transform(source, new StreamResult(writer)); assertThat("Invalid result", writer.toString(), isSimilarTo(XML)); }
/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLStreamReader}. * * @param streamReader the StAX stream reader * @return a source wrapping the {@code streamReader} */ public static Source createCustomStaxSource(XMLStreamReader streamReader) { return new StaxSource(streamReader); }
/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLEventReader}. * * @param eventReader the StAX event reader * @return a source wrapping the {@code eventReader} */ public static Source createCustomStaxSource(XMLEventReader eventReader) { return new StaxSource(eventReader); }
/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLStreamReader}. * @param streamReader the StAX stream reader * @return a source wrapping the {@code streamReader} */ public static Source createCustomStaxSource(XMLStreamReader streamReader) { return new StaxSource(streamReader); }
/** * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLEventReader}. * @param eventReader the StAX event reader * @return a source wrapping the {@code eventReader} */ public static Source createCustomStaxSource(XMLEventReader eventReader) { return new StaxSource(eventReader); }