Class: XML::SAX::Filter

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/xml-sax-machines/filter.rb

Overview

SAX Filter base class.

Chain SAX filters together by delegating missing SAX event methods to the next filter in the chain. Simply call super in any SAX event methods you overload to pass the call to the next filter in the chain.

Extend this Class rather than Nokogiri::XML::SAX::Document which acts as a final filter.

Notes

Filter chains are built in reverse by setting the filter attribute. Use XML::SAX::Pipeline to construct filter chains in a more logical order. This keeps the filter constructor clear of any prerequisite API in subclasses.

See

  • XML::SAX::Pipeline

  • Nokogiri::XML::SAX::Document

– TODO:

  • Examples.

Direct Known Subclasses

Builder, Debug, Pipeline

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filterObject

Barf if the filter isn’t a Nokogiri::XML::SAX::Document or XML::SAX::Filter. The next filter in the chain.



27
28
29
# File 'lib/xml-sax-machines/filter.rb', line 27

def filter
  @filter
end

Instance Method Details

#cdata_block(string) ⇒ Object

:nodoc:



29
30
31
# File 'lib/xml-sax-machines/filter.rb', line 29

def cdata_block(string) #:nodoc:
  @filter.cdata_block(string) if @filter
end

#characters(string) ⇒ Object

:nodoc:



33
34
35
# File 'lib/xml-sax-machines/filter.rb', line 33

def characters(string) #:nodoc:
  @filter.characters(string) if @filter
end

#comment(string) ⇒ Object

:nodoc:



37
38
39
# File 'lib/xml-sax-machines/filter.rb', line 37

def comment(string) #:nodoc:
  @filter.comment(string) if @filter
end

#end_documentObject

:nodoc:



41
42
43
# File 'lib/xml-sax-machines/filter.rb', line 41

def end_document #:nodoc:
  @filter.end_document if @filter
end

#end_element(name) ⇒ Object

:nodoc:



45
46
47
# File 'lib/xml-sax-machines/filter.rb', line 45

def end_element(name) #:nodoc:
  @filter.end_element(name) if @filter
end

#end_element_namespace(name, prefix = nil, uri = nil) ⇒ Object

:nodoc:



49
50
51
# File 'lib/xml-sax-machines/filter.rb', line 49

def end_element_namespace(name, prefix = nil, uri = nil) #:nodoc:
  @filter.end_element_namespace(name, attributes, prefix, uri, ns) if @filter
end

#error(string) ⇒ Object

:nodoc:



53
54
55
# File 'lib/xml-sax-machines/filter.rb', line 53

def error(string) #:nodoc:
  @filter.error(string) if @filter
end

#start_documentObject

:nodoc:



57
58
59
# File 'lib/xml-sax-machines/filter.rb', line 57

def start_document #:nodoc:
  @filter.start_document if @filter
end

#start_element(name, attributes = []) ⇒ Object

:nodoc:



61
62
63
# File 'lib/xml-sax-machines/filter.rb', line 61

def start_element(name, attributes = []) #:nodoc:
  @filter.start_element(name, attributes) if @filter
end

#start_element_namespace(name, attributes = [], prefix = nil, uri = nil, ns = []) ⇒ Object

:nodoc:



65
66
67
# File 'lib/xml-sax-machines/filter.rb', line 65

def start_element_namespace(name, attributes = [], prefix = nil, uri = nil, ns = []) #:nodoc:
  @filter.start_element_namespace(name, attributes, prefix, uri, ns) if @filter
end

#warning(string) ⇒ Object

:nodoc:



69
70
71
# File 'lib/xml-sax-machines/filter.rb', line 69

def warning(string) #:nodoc:
  @filter.warning(string) if @filter
end

#xmldecl(version, encoding, standalone) ⇒ Object



73
74
75
# File 'lib/xml-sax-machines/filter.rb', line 73

def xmldecl(version, encoding, standalone)
  @filter.xmldecl(version, encoding, standalone) if @filter
end