Sha256: 9bf1f39ffc90f05dd5d97ea486366947f9b8033027ca179103983b03d5b3d233

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

#!/usr/bin/ruby

require 'optparse'
require 'schematron-nokogiri'

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 = Nokogiri::XML File.open(schema_file)
  instance_doc = Nokogiri::XML File.open(instance_file)
  stron = SchematronNokogiri::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

3 entries across 3 versions & 1 rubygems

Version Path
schematron-nokogiri-0.0.3 bin/stron-nokogiri
schematron-nokogiri-0.0.2 bin/stron-nokogiri
schematron-nokogiri-0.0.1 bin/stron-nokogiri