Method: CML::Parser#convert

Defined in:
lib/cml/parser.rb

#convert(opts = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cml/parser.rb', line 40

def convert(opts = nil)
  @opts.merge!(opts) if opts
  cloned = @doc.dup
  
  base_nodes = cloned.xpath(BASE_TAGS_XPATH, "xmlns:cml"=>"http://crowdflower.com")
  group_children_nodes = cloned.xpath(GROUP_DESCENDANTS_XPATH, "xmlns:cml"=>"http://crowdflower.com")
  
  (base_nodes - group_children_nodes).each_with_index do |node, i|
    node.namespace = nil
    real_index = base_nodes.index( node )
    node.replace(self.tags[real_index].convert(opts))
  end
  cloned
end