public Source getSource() { Source source = null; if (canInputStream()) { InputStream inputStream = openInputStream(); // Return stream source as a first option. It is less effcient, // but it provides information about line numbers source = new StreamSource(inputStream); } else { source = new DOMSource(node); } source.setSystemId(path); return source; }