public Document loadDocument(GraphRewrite event, EvaluationContext context, XmlFileModel model) throws WindupException
    {
        if (model.asFile().length() == 0)
        {
            final String msg = "Failed to parse, XML file is empty: " + model.getFilePath();
            LOG.log(Level.WARNING, msg);
            model.setParseError(msg);
            throw new WindupException(msg);
        }

        ClassificationService classificationService = new ClassificationService(getGraphContext());

        XMLDocumentCache.Result cacheResult = XMLDocumentCache.get(model);
        if (cacheResult.isParseFailure())
        {
            final String msg = "Not loading XML file '" + model.getFilePath() + "' due to previous parse failure: " + model.getParseError();
            LOG.log(Level.FINE, msg);
            //model.setParseError(msg);
            throw new WindupException(msg);
        }

        Document document = cacheResult.getDocument();
        if (document != null)
            return document;

        // Not yet cached - load, store in cache and return.
        try (InputStream is = model.asInputStream())
        {
            document = LocationAwareXmlReader.readXML(is);
            XMLDocumentCache.cache(model, document);
        }
        catch (SAXException | IOException e)
        {
            XMLDocumentCache.cacheParseFailure(model);
            document = null;
            final String message = "Failed to parse XML file: " + model.getFilePath() + ", due to: " + e.getMessage();
            LOG.log(Level.WARNING, message);
            classificationService.attachClassification(event, context, model, UNPARSEABLE_XML_CLASSIFICATION, UNPARSEABLE_XML_DESCRIPTION);
            model.setParseError(message);
            throw new WindupException(message, e);
        }

        return document;
    }
public Document loadDocument ( GraphRewrite event , EvaluationContext context , XmlFileModel model ) throws WindupException { if ( model . asFile ( ) . length ( ) == 0 ) { final String msg = "Failed to parse, XML file is empty: " + model . getFilePath ( ) ; LOG . log ( Level . WARNING , msg ) ; model . setParseError ( msg ) ; throw new WindupException ( msg ) ; } ClassificationService classificationService = new ClassificationService ( getGraphContext ( ) ) ; XMLDocumentCache . Result cacheResult = XMLDocumentCache . get ( model ) ; if ( cacheResult . isParseFailure ( ) ) { final String msg = "Not loading XML file '" + model . getFilePath ( ) + "' due to previous parse failure: " + model . getParseError ( ) ; LOG . log ( Level . FINE , msg ) ; throw new WindupException ( msg ) ; } Document document = cacheResult . getDocument ( ) ; if ( document != null ) return document ; try ( InputStream is = model . asInputStream ( ) ) { document = LocationAwareXmlReader . readXML ( is ) ; XMLDocumentCache . cache ( model , document ) ; } catch ( SAXException | IOException e ) { XMLDocumentCache . cacheParseFailure ( model ) ; document = null ; final String message = "Failed to parse XML file: " + model . getFilePath ( ) + ", due to: " + e . getMessage ( ) ; LOG . log ( Level . WARNING , message ) ; classificationService . attachClassification ( event , context , model , UNPARSEABLE_XML_CLASSIFICATION , UNPARSEABLE_XML_DESCRIPTION ) ; model . setParseError ( message ) ; throw new WindupException ( message , e ) ; } return document ; }
Loads and parses the provided XML file. This will quietly fail (not throwing an {@link Exception}) and return
null if it is unable to parse the provided {@link XmlFileModel}. A {@link ClassificationModel} will be created to
indicate that this file failed to parse.

@return Returns either the parsed {@link Document} or null if the {@link Document} could not be parsed