lib/sdr/sdr_base.rb
def validate_xml(xmlString, xmlSchemaString, root_element=nil)
        xml_doc = Nokogiri::XML(xmlString)
        xml_schema = Nokogiri::XML::Schema(xmlSchemaString)
        if root_element
          errors = xml_schema.validate(xml_doc.xpath("//#{root_element}").first)
        else
          errors = xml_schema.validate(xml_doc)
        end
        errors.empty?
      end
# Validate XML against an XML schema definition (XSD).
# @param [String] xmlString a xml string that will be parsed by Nokogiri::XML
# @param [String] xmlSchemaString a xml schema string that will be parsed by Nokogiri::XML::Schema
Validate XML against an XML schema definition (XSD).
Validate XML against an XML schema definition ( XSD ) .
def validate_xml(xmlString, xmlSchemaString, root_element=nil)
        xml_doc = Nokogiri::XML(xmlString)
        xml_schema = Nokogiri::XML::Schema(xmlSchemaString)
        if root_element
          errors = xml_schema.validate(xml_doc.xpath("//#{root_element}").first)
        else
          errors = xml_schema.validate(xml_doc)
        end
        errors.empty?
      end
def validate_xml ( xmlString , xmlSchemaString , root_element = nil ) xml_doc = Nokogiri :: XML ( xmlString ) xml_schema = Nokogiri :: XML :: Schema ( xmlSchemaString ) if root_element errors = xml_schema . validate ( xml_doc . xpath ( "//#{root_element}" ) . first ) else errors = xml_schema . validate ( xml_doc ) end errors . empty? end
Validate XML against an XML schema definition (XSD).
Validate XML against an XML schema definition ( XSD ) .
xmlString
xmlSchemaString
root_element
xmlSchemaString a xml schema string that will be parsed by Nokogiri::XML::Schema
xmlSchemaString a xml schema string that will be parsed by Nokogiri :: XML :: Schema