schxslt / schxslt-java

Java classes for Schematron validation with SchXslt
MIT License
7 stars 4 forks source link

Javacodingimprovements #40

Closed eduarddrenth closed 4 years ago

eduarddrenth commented 4 years ago

Some code improvements and docs

eduarddrenth commented 4 years ago

The transformerFactory field is now private. The only way to change the factory is via withTransformerFactory(). This should be sufficient for thread safety, shouldn't it?

Well...not exactly, what matters is if the methods can be called from multiple threads. Saxonica transformerfactory methods can be called concurrently from multiple threads, xalan transformerfactory is not threadsafe.

But... since you call one transformerFactory method during instanciation and the other from validate in a synchronized block, you're safe. You don't have to synchronize in withResolver by the way, since you operate on a new Schematron there

dmj commented 4 years ago

You don't have to synchronize in withResolver by the way, since you operate on a new Schematron there.

The Schematron is new but it might have a shared TransformerFactory.

eduarddrenth commented 4 years ago

You don't have to synchronize in withResolver by the way, since you operate on a new Schematron there.

The Schematron is new but it might have a shared TransformerFactory.

Yes, very good, makes me think if this is desirable, in #validate this now shared transformerfactory is used, synchronizing on different schematron instances. Perhaps new Schenatron should always create a new TransformerFactory.

eduarddrenth commented 4 years ago

Added some improvements among which one bugfix (tf not passed)

eduarddrenth commented 4 years ago

Added some improvements among which one bugfix (tf not passed).

Turned saxon (update to 10?) into runtime dependency, which is not realy necessary for users stick to xslt1. If users want to use another implementation they can always exclude saxon and plugin their own.

dmj commented 4 years ago

Thanks, merged to master.