Class: Rng::RngParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rng/rng_parser.rb

Constant Summary collapse

RELAXNG_NS =
"http://relaxng.org/ns/structure/1.0"

Instance Method Summary collapse

Instance Method Details

#parse(input) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rng/rng_parser.rb', line 9

def parse(input)
  doc = Nokogiri::XML(input)
  doc.remove_namespaces! # This simplifies namespace handling

  root = doc.root
  case root.name
  when "grammar"
    parse_grammar(doc)
  when "element"
    parse_element(doc)
  else
    raise Rng::Error, "Unexpected root element: #{root.name}"
  end
end