Refine search
@Override protected Object unmarshalStreamSource(StreamSource streamSource) throws XmlMappingException, IOException { if (streamSource.getInputStream() != null) { return unmarshalInputStream(streamSource.getInputStream()); } else if (streamSource.getReader() != null) { return unmarshalReader(streamSource.getReader()); } else { throw new IllegalArgumentException("StreamSource contains neither InputStream nor Reader"); } }
/** * Close the underlying resource managed by the supplied {@link Source} if applicable. * <p>Only works for {@link StreamSource StreamSources}. * @param source the XSLT Source to close (may be {@code null}) */ private void closeSourceIfNecessary(@Nullable Source source) { if (source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; if (streamSource.getReader() != null) { try { streamSource.getReader().close(); } catch (IOException ex) { // ignore } } if (streamSource.getInputStream() != null) { try { streamSource.getInputStream().close(); } catch (IOException ex) { // ignore } } } }
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }
/** * Close the underlying resource managed by the supplied {@link Source} if applicable. * <p>Only works for {@link StreamSource StreamSources}. * @param source the XSLT Source to close (may be {@code null}) */ private void closeSourceIfNecessary(@Nullable Source source) { if (source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; if (streamSource.getReader() != null) { try { streamSource.getReader().close(); } catch (IOException ex) { // ignore } } if (streamSource.getInputStream() != null) { try { streamSource.getInputStream().close(); } catch (IOException ex) { // ignore } } } }
if (streamSource.getInputStream() != null) { inputSource = new InputSource(streamSource.getInputStream()); else if (streamSource.getReader() != null) { inputSource = new InputSource(streamSource.getReader());
if (streamSource.getInputStream() != null) { if (isProcessExternalEntities() && isSupportDtd()) { return unmarshalInputStream(streamSource.getInputStream()); InputSource inputSource = new InputSource(streamSource.getInputStream()); inputSource.setEncoding(getDefaultEncoding()); return unmarshalSaxSource(new SAXSource(inputSource)); else if (streamSource.getReader() != null) { if (isProcessExternalEntities() && isSupportDtd()) { return unmarshalReader(streamSource.getReader()); return unmarshalSaxSource(new SAXSource(new InputSource(streamSource.getReader())));
/** * Transform summary information to HTML. * * @param htmlWriter * the Writer to write the HTML output to */ public void transformSummaryToHTML(Writer htmlWriter) throws IOException, TransformerException { ByteArrayOutputStream summaryOut = new ByteArrayOutputStream(8096); reportSummary(summaryOut); StreamSource in = new StreamSource(new ByteArrayInputStream(summaryOut.toByteArray())); StreamResult out = new StreamResult(htmlWriter); InputStream xslInputStream = this.getClass().getClassLoader().getResourceAsStream("summary.xsl"); if (xslInputStream == null) { throw new IOException("Could not load summary stylesheet"); } StreamSource xsl = new StreamSource(xslInputStream); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(xsl); transformer.transform(in, out); Reader rdr = in.getReader(); if (rdr != null) { rdr.close(); } htmlWriter.close(); InputStream is = xsl.getInputStream(); if (is != null) { is.close(); } }
/** * Attempt to obtain a SAX InputSource object from a Source * object. * * @param source Must be a non-null Source reference. * * @return An InputSource, or null if Source can not be converted. */ public static InputSource sourceToInputSource(Source source) { if (source instanceof SAXSource) { return ((SAXSource) source).getInputSource(); } else if (source instanceof StreamSource) { StreamSource ss = (StreamSource) source; InputSource isource = new InputSource(ss.getSystemId()); isource.setByteStream(ss.getInputStream()); isource.setCharacterStream(ss.getReader()); isource.setPublicId(ss.getPublicId()); return isource; } else { return null; } } }
/** * This class wraps an ErrorListener into a MessageHandler in order to * capture messages reported via xsl:message. */ static class MessageHandler extends org.apache.xalan.xsltc.runtime.MessageHandler { private ErrorListener _errorListener; public MessageHandler(ErrorListener errorListener) { _errorListener = errorListener; } public void displayMessage(String msg) { if(_errorListener == null) { System.err.println(msg); } else { try { _errorListener.warning(new TransformerException(msg)); } catch (TransformerException e) { // ignored } } } }
final InputStream streamInput = stream.getInputStream(); final Reader streamReader = stream.getReader(); final XMLReader reader = _readerManager.getXMLReader();
((StreamSource)source).getInputStream()==null && ((StreamSource)source).getReader()==null)|| (source instanceof SAXSource && ((SAXSource)source).getInputSource()==null &&
((StreamSource)source).getInputStream()==null && ((StreamSource)source).getReader()==null)|| (source instanceof SAXSource && ((SAXSource)source).getInputSource()==null &&
final InputStream istream = stream.getInputStream(); final Reader reader = stream.getReader();
((StreamSource)source).getInputStream()==null && ((StreamSource)source).getReader()==null)|| (source instanceof SAXSource && ((SAXSource)source).getInputSource()==null &&
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }
((StreamSource)source).getInputStream()==null && ((StreamSource)source).getReader()==null)|| (source instanceof SAXSource && ((SAXSource)source).getInputSource()==null &&
((StreamSource)source).getInputStream()==null && ((StreamSource)source).getReader()==null)|| (source instanceof SAXSource && ((SAXSource)source).getInputSource()==null &&
InputSource inputStream; if (stream.getInputStream() == null && stream.getReader() != null) { inputStream = new InputSource(stream.getReader()); } else { inputStream = new InputSource(stream.getInputStream());
public XMLStreamReader createXMLStreamReader(Source src) throws XMLStreamException { // Can only support simplest of sources: if (src instanceof StreamSource) { StreamSource ss = (StreamSource) src; InputStream in = ss.getInputStream(); String systemId = ss.getSystemId(); if (in != null) { if (systemId != null) { return createXMLStreamReader(systemId, in); } return createXMLStreamReader(in); } Reader r = ss.getReader(); if (r != null) { if (systemId != null) { return createXMLStreamReader(systemId, r); } return createXMLStreamReader(r); } throw new UnsupportedOperationException("Only those javax.xml.transform.stream.StreamSource instances supported that have an InputStream or Reader"); } throw new UnsupportedOperationException("Only javax.xml.transform.stream.StreamSource type supported"); }