-
-
Notifications
You must be signed in to change notification settings - Fork 935
Closed
Milestone
Description
With Nokogiri 1.5.5 on JRuby validating an empty document does not result in an error, while with MRI it does.
If you try the below snippet in MRI and JRuby (XML schema taken from #642, perhaps there is some relation between the issues -- atleast for JRuby):
require 'nokogiri'
xsd_data = <<-XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/contactExample"
xmlns:tns="http://www.example.org/contactExample"
elementFormDefault="qualified">
<xs:element name="Contacts"></xs:element>
</xs:schema>
XSD
xsd = Nokogiri::XML::Schema.new(xsd_data)
empty_xml = Nokogiri::XML("")
xsd.validate(empty_xml)
#=> MRI: [#<Nokogiri::XML::SyntaxError: The document has no document element.>]
#=> JRuby: []
xsd.valid?(empty_xml)
#=> MRI: false
#=> JRuby: trueReactions are currently unavailable