class Nokogiri::XML::Schema
the ParseOptions to re-enable external entity resolution over a network connection.
security policy. If a document is trusted, then the caller may turn off the NONET option via
documents as “trusted” by default which was counter to Nokogiri’s “untrusted by default”
are not resolved from the network (‘http://` or `ftp://`). Previously, parsing treated
NOTE: As of v1.11.0, Schema treats inputs as UNTRUSTED by default, and so external entities
The list of errors are Nokogiri::XML::SyntaxError objects.
end
puts error.message
xsd.validate(doc).each do |error|
doc = Nokogiri::XML(File.read(PO_XML_FILE))
xsd = Nokogiri::XML::Schema(File.read(PO_SCHEMA_FILE))
are returned and print them out:
Validate an XML document against a Schema. Loop over the errors that
== Synopsis
(usually from an xsd file).
Nokogiri::XML::Schema is used for validating XML against a schema
##
def self.new(string_or_io, options = ParseOptions::DEFAULT_SCHEMA)
Create a new Nokogiri::XML::Schema object using a +string_or_io+
##
def self.new(string_or_io, options = ParseOptions::DEFAULT_SCHEMA) from_document(Nokogiri::XML(string_or_io), options) end
def valid?(thing)
Returns true if +thing+ is a valid Nokogiri::XML::Document or
##
def valid?(thing) validate(thing).empty? end
def validate(thing)
Nokogiri::XML::SyntaxError objects found while validating the
Nokogiri::XML::Document object, or a filename. An Array of
Validate +thing+ against this schema. +thing+ can be a
##
def validate(thing) if thing.is_a?(Nokogiri::XML::Document) validate_document(thing) elsif File.file?(thing) validate_file(thing) else raise ArgumentError, "Must provide Nokogiri::Xml::Document or the name of an existing file" end end