class NamespaceAwareXmlDocumentBuilder implements XmlDocumentBuilder {

    @Override
    public Document buildDocument(final InputStream inputStream, final Schema schema) throws DocumentBuilderException {
        try {
            DocumentBuilderFactory dbFactory = documentBuilderFactoryBuilder.buildDocumentBuilderFactory();
            dbFactory.setNamespaceAware(true);
            dbFactory.setSchema(schema);
            DocumentBuilder documentBuilder = dbFactory.newDocumentBuilder();
            Document document = documentBuilder.parse(inputStream);
            document.getDocumentElement().normalize();
            return document;
        } catch (Exception e) {
            throw new DocumentBuilderException("Exception while trying to parse XML document", e);
        }

    }

}