class HealthDataStandards::Validate::Schematron::Validator

Public Class Methods

new(name,schematron_file) click to toggle source
# File lib/health-data-standards/validate/schematron_validator.rb, line 19
def initialize(name,schematron_file)
  @name = name
  @schematron_file = schematron_file
end

Public Instance Methods

validate(document,data = {}) click to toggle source
# File lib/health-data-standards/validate/schematron_validator.rb, line 24
def validate(document,data = {})
  file_errors = document.errors.select { |e| e.fatal? || e.error? }
  if file_errors
    file_errors.each do |error|
      build_error(error, '/', data[:file_name])
    end
  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