stevedlawrence opened a new pull request, #1517: URL: https://github.com/apache/daffodil/pull/1517
The currently validator API supports all the features needed to support our existing and custom validators. However, it does add extra complication, since API users must create a Properties instance, find the ValidatorFactory, use that and the Properties to create a Validator, and provide that Validator to the DataProcessor. Although this provides much flexibility, it is flexibility that API users rarely need. The new API is now `DataProcessor.withValidation(String, URI)` where the String is the name of a validator to use (looked up via SPI), and the URI is either a properties file or a file that the Validator can use for validation (e.g. XSD for "xerces", .sch or XSD with embedded schematron rules for "schematron"). This new function uses those parameters and the existing ValidatorFactory API to create and assign the validator to the DataProcessor. Additional changes include: - The converter in Main.scala no longer creates a validator, instead it just parses the validation option into a `(String, Option[URI])` that is passed to the new withValidation function. This means creating the validator can fail when withValidation is called (e.g. if the validator does not exist) and so the CLI adds new exit codes to handle the possible validation failures. If the optional validator value is not provided, we provide the DFDL schema as the URI. - The CLI was setting the validator twice, when when creating the processor and again when setting variables/debug/etc. This removes the duplicates. - The daffodil.rootSchema property cannot be needed now, since withValidation doesn't know if the provided URI is actually the DFDL schema. Instead, validators now only use properties specific to the validator. - makeValidator can never get a null Properties instance now, so the null check is removed - We now require that validators are found via SPI. Two tests are removed that explicitly tested non-SPI behavior. - Add a missing catch if schematron fails to read the .sch file. Previously this would throw a generic exception caught by scallop when creating the validator, but it really should be caught by the SchematronValidator and returned as an initialization exception. - The TDMLRunner is modified so it only ever knows about "on", "limited" and "off" validation modes. It then passes those unmodified strings directly to the TDMLDFDLProcessor implementation, which must convert the to whatever the implementation uses for validation. The DaffodilTDMLDFDLProcessor now keeps track of the schema URI and uses the new DataProcessor.withValidation, passing in the validation mode (converting "on" to "xerces") and the schema URI. - The validation package-info.java file is changed to focus on the validator names and properties instead of the implementations, since users don't really need to care about ValidatorFactories's or Validators as much with the new API DAFFODIL-3013 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
