private static Document parseIncludeFile(FileWrapper file, String parentTagName, boolean required) throws IOException {
        StringWriter w = new StringWriter();
        final String startTag = "<" + parentTagName + " " + XmlPreProcessor.deployNamespace + "='" + XmlPreProcessor.deployNamespaceUri + "' " + XmlPreProcessor.preprocessNamespace + "='" + XmlPreProcessor.preprocessNamespaceUri + "'>";
        w.append(startTag);
        if (file.exists() || required) {
            w.append(new String(file.content(), UTF_8));
        }
        final String endTag = "</" + parentTagName + ">";
        w.append(endTag);
        return XML.getDocument(new StringReader(w.toString()));
    }
Handles preprocess:include statements and returns a Document which has all the include statements resolved

@author hmusum
config-application-package/src/main/java/com/yahoo/config/application/IncludeProcessor.java