class CqmValidators::Schematron::Validator
Public Class Methods
new(name, schematron_file)
click to toggle source
# File lib/schematron_validator.rb, line 20 def initialize(name, schematron_file) @name = name @schematron_file = schematron_file end
Public Instance Methods
validate(document, data = {})
click to toggle source
# File lib/schematron_validator.rb, line 25 def validate(document, data = {}) file_errors = get_document(document).errors.select { |e| e.fatal? || e.error? } file_errors&.each do |error| build_error(error, '/', data[:file_name]) end errors = get_errors(document).root.xpath('//svrl:failed-assert', NAMESPACE).map do |el| build_error(el.xpath('svrl:text', NAMESPACE).text, el['location'], data[:file_name]) end errors.uniq { |e| "#{e.location}#{e.message}" } end