Open tjdett opened 11 years ago
This behaviour can be confirmed using the Atom RELAX NG XML schema and Nokogiri:
require 'atom'
require 'open-uri'
require 'nokogiri'
def make_feed(complete = false)
Atom::Feed.new do |feed|
# Order is important
feed.id = "http://example.test/feed"
feed.updated = DateTime.now
feed.title = 'Test Feed'
if complete
# Mark feed as complete
feed['http://purl.org/syndication/history/1.0', 'complete'] << ''
end
# Add entries
feed.entries << Atom::Entry.new do |entry|
entry.id = "http://example.test/entry/1"
entry.updated = feed.updated
entry.title = 'Test Entry'
end
end
end
gist = 'https://gist.github.com/raw/4617547'
rng_schema_url = "#{gist}/e223befbbf04fe4a625152d59c0853fd9b88ec7e/atom.rng.xml"
schema = Nokogiri::XML::RelaxNG(URI.parse(rng_schema_url).open)
doc = Nokogiri::XML(make_feed.to_xml)
puts "Errors without simple extension: #{schema.validate(doc).inspect}"
doc = Nokogiri::XML(make_feed(true).to_xml)
puts "Errors with simple extension: #{schema.validate(doc).inspect}"
Hi,
That's a good catch. Would you be up for turning the above test into a spec in a pull request?
I'll have to have a look at Parseable
to figure out the best way of resolving that... but a failing spec is a good first step.
From http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.feed:
The spec requires extension elements to occur before atom entries. This doesn't happen because of the generic way
Atom::XML::Parseable
is implemented - they always come last inside their enclosing element.