protected XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is) {
DocumentDepthProperties props = getDepthProperties();
if (props != null && props.isEffective()) {
reader = TransformUtils.createNewReaderIfNeeded(reader, is);
reader = new DepthRestrictingStreamReader(reader, props);
} else if (reader != null) {
reader = configureReaderRestrictions(reader);
}
return reader;
}