Class Nokogiri::XML::Schema
In: lib/nokogiri/ffi/xml/schema.rb
lib/nokogiri/xml/schema.rb
ext/nokogiri/html_document.c
Parent: Object

Nokogiri::XML::Schema is used for validating XML against a schema (usually from an xsd file).

Synopsis

Validate an XML document against a Schema. Loop over the errors that are returned and print them out:

  xsd = Nokogiri::XML::Schema(File.read(PO_SCHEMA_FILE))
  doc = Nokogiri::XML(File.read(PO_XML_FILE))

  xsd.validate(doc).each do |error|
    puts error.message
  end

The list of errors are Nokogiri::XML::SyntaxError objects.

Methods

Attributes

errors  [RW]  Errors while parsing the schema file

Public Class methods

Create a new Nokogiri::XML::Schema object using a string_or_io object.

Create a new Schema from the contents of string

Public Instance methods

Returns true if thing is a valid Nokogiri::XML::Document or file.

Validate thing against this schema. thing can be a Nokogiri::XML::Document object, or a filename. An Array of Nokogiri::XML::SyntaxError objects found while validating the thing is returned.

[Validate]