Module: Duxml::Saxer

Included in:
Duxml
Defined in:
lib/duxml/saxer.rb

Defined Under Namespace

Classes: DocuLiner

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ioObject

Returns the value of attribute io.



9
10
11
# File 'lib/duxml/saxer.rb', line 9

def io
  @io
end

Instance Method Details

#sax(path, obs = nil) ⇒ Doc

Returns finished document with each Element’s line and column info added.

Parameters:

  • path (String)

    path of file to parse

Returns:

  • (Doc)

    finished document with each Element’s line and column info added



12
13
14
15
16
17
18
19
20
# File 'lib/duxml/saxer.rb', line 12

def sax(path, obs=nil)
  io = File.open path
  saxer = DocuLiner.new(Duxml::Doc.new, obs)
  Ox.sax_parse(saxer, io, {convert_special: true, symbolize: false})
  doc = saxer.cursor
  doc.add_observer obs if obs and doc.count_observers < 1
  doc.path = path
  doc
end