# Helps to validate xml against schemas contained in a WSDL class WsdlValidator # @param [String] wsdl_url URL to where WSDL is stored def initialize(wsdl_url) @doc = Wasabi.document wsdl_url @schemas = @doc.parser.schemas.collect(&:to_s).join end # @param [String, Nokogiri::XML::NodeSet] xml # @return [Boolean] Whether xml is valid according to WSDL of class def valid?(xml) raise "Incorrect type #{xml.class}" unless [String, Nokogiri::XML::Document, Nokogiri::XML::NodeSet].include? xml.class xml_under_test = Nokogiri::XML(xml.to_s) xsd = Nokogiri::XML::Schema(@schemas) validator = xsd.validate(xml_under_test) validator.each { |error| puts error.message } return false unless validator.empty? true end end