module Rss20 class Item < Element element :author, :email element :category, MANY element :comments, :rfc2396_full element :description, :safehtml element :enclosure element :guid, :unique element :link, REQUIRED element :pubDate, :rfc822 element :source element :title, :nonhtml def end_element *args unless @children.include?('title') or @children.include?('description') log :ItemMustContainTitleOrDescription end end end class Cloud < Element def initialize parent super @valid = true end attribute :domain, REQUIRED attribute :path, REQUIRED attribute :port, :nonNegative attribute :protocol, REQUIRED, :nonNegative attribute :registerProcedure, REQUIRED def log *args @valid = false @parent.log *args end def end_element *args if @valid log :ValidCloud end end end class Channel < Element element :category, MANY element :cloud, Cloud element :copyright element :docs, :rfc2396 element :description, REQUIRED element :generator element :image element :item, MANY, Item element :language, :iso639 element :lastBuildDate, :rfc822 element :link, REQUIRED element :managingEditor, :email element :pubDate, :rfc822 element :skipDays, MANY element :skipHours, MANY element :textinput element :textInput element :title, REQUIRED, :nonhtml, :nonblank element :ttl, :positiveInteger, :nonblank element :webMaster, :email end class Rss < Element attribute :version, REQUIRED element :channel, REQUIRED, Channel end end class Root < Element element :rss, Rss20::Rss element :feed, :missing_namespace end