Sha256: 1f4073f270bd05b632a2dcd35e23d564321ce186e34fbbb0c4ec795723863f06

Contents?: true

Size: 756 Bytes

Versions: 1

Compression:

Stored size: 756 Bytes

Contents

#!/usr/bin/ruby

require 'optparse'
require 'libxml'
require 'schematron'

include LibXML

XML.default_line_numbers = true

begin

  # get args
  schema_file = ARGV.shift or raise "schematron file required"
  instance_file = ARGV.shift or raise "instance doc file required"

  # parse the xml
  schema_doc = XML::Document.file schema_file
  instance_doc = XML::Document.file instance_file
  stron = Schematron::Schema.new schema_doc

  # validate
  errors = stron.validate(instance_doc)
  if errors.empty?
    exit 0
  else

    errors.each do |error|
      puts '%s "%s" on line %d: %s' % error.values_at(:type, :name, :line, :message)
    end

    exit 1
  end

rescue => e
  puts "Usage: stron [schematron] [instance doc]"
  puts e.message
  exit 2
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schematron-1.1.1 bin/stron