jw3 commented on a change in pull request #431:
URL: https://github.com/apache/incubator-daffodil/pull/431#discussion_r510186887
##########
File path:
daffodil-lib/src/main/scala/org/apache/daffodil/util/DefaultValidator.scala
##########
@@ -100,3 +111,35 @@ object Validator extends NoBindingFactoryAdapter {
}
}
+class DefaultValidatorFactory extends ValidatorFactory {
+ def name(): String = "default" /// todo;; or should it be "xerces"
+
+ // to not muck around too much with the original logic above just wrapping
access to the
+ // object in an adapter for the new Validator behavior
+ def make(config: Option[Config]): Validator = new Validator with
ErrorHandler {
+ private val schemaFiles =
config.map(_.getStringList(name()).asScala).getOrElse(Seq.empty)
+ private var errors = List.empty[ValidationError]
+ private var warnings = List.empty[ValidationWarning]
+ def validateXML(document: InputStream): ValidationResult = {
+ try {
+ DefaultValidator.validateXMLSources(schemaFiles, document, this)
+ ValidationResult(warnings, errors)
+ }
+ catch {
+ //
+ // Some SAX Parse errors are thrown even if you specify an error
handler to the
+ // validator.
+ //
+ // So we also need this catch
+ //
+ case e: SAXException =>
+ errors :+= SaxValidationError(e)
+ ValidationResult(warnings, errors)
+ }
+ }
+
+ override def warning(spe: SAXParseException): Unit = errors :+=
SaxValidationError(spe)
Review comment:
Xerces handling is no longer applicable up in the ParseResult
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]