Sha256: 06bc293ee8017da0eca3fac900b04d2f3bcea189e0a14a60648352585bb377cb

Contents?: true

Size: 724 Bytes

Versions: 10

Compression:

Stored size: 724 Bytes

Contents

class XmlValidator
  require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
  require 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

  include System::Xml
  include System::Xml::Schema

  def self.validate(xml_file, xsd_file)
    xml = File.read(xml_file)

    settings = XmlReaderSettings.new
    settings.validation_type = ValidationType.Schema;
    settings.schemas.add(nil, xsd_file)

    is_valid = true
    settings.validation_event_handler { |s, e|
      is_valid = false if e.severity == XmlSeverityType.error
    }

    reader = XmlReader.create(System::IO::StringReader.new(xml), settings)
    while reader.read
    end

    return is_valid
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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