Skip to content

Commit 865b5f9

Browse files
committed
Make an empty document parse okay rather than error out.
1 parent adf37aa commit 865b5f9

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/rdf/rdfxml/reader.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@ def initialize(input = $stdin, **options, &block)
158158
input.rewind if input.respond_to?(:rewind)
159159
initialize_xml(input, **options) rescue log_fatal($!.message)
160160

161-
log_error("Empty document") if root.nil?
162-
log_error("Synax errors") {doc_errors} if !doc_errors.empty?
161+
if root.nil?
162+
log_info("Empty document")
163+
elsif !doc_errors.empty?
164+
log_error("Synax errors") {doc_errors}
165+
end
163166

164167
block.call(self) if block_given?
165168
end

spec/reader_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
let(:reader_input) {File.read(doap)}
1515
let(:reader) {RDF::RDFXML::Reader.new(reader_input)}
1616
let(:reader_count) {File.open(doap_nt).each_line.to_a.length}
17+
let(:reader_invalid_input) {%(
18+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
19+
<rdf:Description rdf:ID='333-555-666' />
20+
</rdf:RDF>
21+
)}
1722
end
1823

1924
context "discovery" do

0 commit comments

Comments
 (0)