Class: Slaw::Grammars::ZA::Act::BlockElementsWithInline

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/slaw/grammars/za/act_nodes.rb

Instance Method Summary collapse

Instance Method Details

#to_xml(b, idprefix = '') ⇒ Object



268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/slaw/grammars/za/act_nodes.rb', line 268

def to_xml(b, idprefix='')
  b.content { |b|
    kids = [first_child] + children.elements
    kids = kids.select { |k| k and !k.text_value.strip.empty? }

    if kids.empty?
      # schema requires a non-empty content element
      b.p
    else
      kids.each_with_index { |e, i| e.to_xml(b, idprefix, i) }
    end
  }
end