Sha256: adf96c63c2a6fdc2243fa29f10ef3366aab438d0db0e64e3e908b9829dbf5202

Contents?: true

Size: 351 Bytes

Versions: 10

Compression:

Stored size: 351 Bytes

Contents

require 'nokogiri'

class XmlValidator
  def self.validate(xml_file, schema_file)
    schema = Nokogiri::XML::Schema(File.read(schema_file))
    doc = Nokogiri::XML::Document.parse(File.read(xml_file))

    validation = schema.validate(doc)
    validation.each do |error|
      raise error.message
    end

    return validation.length == 0
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
albacore-0.3.6 spec/support/nokogiri_validator.rb
albacore-1.0.0.rc.2 spec/support/nokogiri_validator.rb
albacore-1.0.0.rc.1 spec/support/nokogiri_validator.rb
albacore-0.3.5 spec/support/nokogiri_validator.rb
albacore-0.3.4 spec/support/nokogiri_validator.rb
albacore-0.3.3 spec/support/nokogiri_validator.rb
albacore-0.3.2 spec/support/nokogiri_validator.rb
albacore-0.3.1 spec/support/nokogiri_validator.rb
albacore-0.3.0 spec/support/nokogiri_validator.rb
albacore-0.2.6 spec/support/nokogiri_validator.rb