itplr-kosit / validator

Validates XML documents with XML Schema and Schematron
Apache License 2.0
80 stars 42 forks source link

Caching in ContentRepository #50

Closed awltr closed 4 years ago

awltr commented 4 years ago

If you use the project as API, the scenarios and all xslt are read in at each validation. This is very costly in terms of performance. Would it be possible to implement a caching? I could also do a PR for it.

apenski commented 4 years ago

You should reuse the Check instance. All scenario-stuff (xslt, schema etc.) is only read once on initialisation. E.g do this

Configuration config = Configuration.load(...).build();
Check check = new DefaultCheck(config); // all runtime artifacts are loaded here!

check.checkInput(yourInput1);
check.checkInput(yourInput2);
check.checkInput(yourInput3);
...
awltr commented 4 years ago

That's a good point. I could have really come up with that myself :). Thanks!