Steve Lawrence created DAFFODIL-3013:
----------------------------------------
Summary: Consider simplified Validator API
Key: DAFFODIL-3013
URL: https://issues.apache.org/jira/browse/DAFFODIL-3013
Project: Daffodil
Issue Type: Bug
Components: API
Affects Versions: 4.0.0
Reporter: Steve Lawrence
Fix For: 4.0.0
The new Validator API provides all the necessary functionality to create and
configure custom validators in a consistent way. But with it comes extra
complexity for API users--they must create a validator factory, create a
Properties instance with the correct values, and make the validator. While this
design is probably the right approach to support custom/pluggable validators,
much of this complexity can probably be hidden behind the scenes for API users.
For example, ideal examples of ways to set a validator could look like this:
DataProcessor.withValidator("limited")
DataProcessor.withValidator("xerces", new URI(".../path/to/schema.dfdl.xsd")))
DataProcessor.withValidator("schematron", new URI(".../path/to/schematron.sch")
DataProcessor.withValidator("customValidator", new
URI(".../path/to/file.properties")
If the uri parameter ends in .properties or .config, we use Properties.load()
to create a Properties instance. Otherwise we create a new Properties instance
and call setProperty(name, uri.toString).
Then we call Validator.get(name).make(properties) to create the validator, and
finally call DataProcessor.withValidator(validator) to actually set the
validator.
If we want we can still have the DataProcessor.withValidator(Validator) API
variant be public for those that really want to do it all manually, but it
probably wouldn't be the usual way for most API users, since the other
functions are simpler and provide basically the same functionality.
This is also nice since it should move some of the logic to create Validators
out of the CLI and into the API, simplifying the CLI a bit. This also could
simplify the TDMLRunner, which also has similar logic for creating Validators.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)