Sha256: 4c3fa035a590e420fed39630337d1dec03d89cbb83fc3d93662c15367f6fb6b4

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module HealthDataStandards
  module Validate
    module Schematron
    NAMESPACE = {"svrl" => "http://purl.oclc.org/dsdl/svrl"}
    DIR = File.expand_path("../../../../", __FILE__)
    ISO_SCHEMATRON = File.join(DIR, 'resources/schematron/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl')

      class Validator
        include BaseValidator

        if RUBY_PLATFORM != "java"
          require_relative "schematron/c_processor"
          include Schematron::CProcessor
        else
          require_relative 'schematron/java_processor'
          include Schematron::JavaProcessor
        end

        def initialize(name,schematron_file)
          @name = name
          @schematron_file = schematron_file
        end

        def validate(document,data = {})
          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

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
health-data-standards-3.6.1 lib/health-data-standards/validate/schematron_validator.rb