*/
protected XMLStreamReader2 createSR(javax.xml.transform.Source src,
boolean forER)
throws XMLStreamException
{
ReaderConfig cfg = createPrivateConfig();
Reader r = null;
InputStream in = null;
String pubId = null;
String sysId = null;
String encoding = null;
boolean autoCloseInput;
if (src instanceof Stax2Source) {
/* 16-Aug-2006, TSa: Should have more optimized handling
* for specific types
*/
Stax2Source ss = (Stax2Source) src;
sysId = ss.getSystemId();
pubId = ss.getPublicId();
encoding = ss.getEncoding();
try {
in = ss.constructInputStream();
if (in == null) {
r = ss.constructReader();
}
} catch (IOException ioe) {
throw new WstxIOException(ioe);
}
/* Caller has no direct access to stream/reader, Woodstox
* owns it and thus has to close too
*/
autoCloseInput = true;
} else if (src instanceof StreamSource) {
StreamSource ss = (StreamSource) src;
sysId = ss.getSystemId();
pubId = ss.getPublicId();
in = ss.getInputStream();
if (in == null) {
r = ss.getReader();
}
/* Caller still has access to stream/reader; no need to
* force auto-close-input
*/
autoCloseInput = cfg.willAutoCloseInput();
} else if (src instanceof SAXSource) {
SAXSource ss = (SAXSource) src;
/* 28-Jan-2006, TSa: Not a complete implementation, but maybe
* even this might help...
*/
InputSource isrc = ss.getInputSource();
if (isrc != null) {
sysId = isrc.getSystemId();
pubId = isrc.getPublicId();
encoding = isrc.getEncoding();
in = isrc.getByteStream();
if (in == null) {
r = isrc.getCharacterStream();
}
}
/* Caller still has access to stream/reader; no need to
* force auto-close-input
*/
autoCloseInput = cfg.willAutoCloseInput();
} else if (src instanceof DOMSource) {
DOMSource domSrc = (DOMSource) src;
// SymbolTable not used by the DOM-based 'reader':
return DOMWrappingReader.createFrom(cfg, domSrc);
} else {