Class: WsdlMapper::Deserializers::SaxDocument
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- WsdlMapper::Deserializers::SaxDocument
- Includes:
- WsdlMapper::Dom
- Defined in:
- lib/wsdl_mapper/deserializers/sax_document.rb
Constant Summary collapse
- XSI_NS =
'http://www.w3.org/2001/XMLSchema-instance'- XSI_TYPE =
WsdlMapper::Dom::Name.get XSI_NS, 'type'
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #cdata_block(text) ⇒ Object
- #characters(text) ⇒ Object
- #end_document ⇒ Object
- #end_element_namespace(name, _prefix = nil, uri = nil) ⇒ Object
-
#initialize(base) ⇒ SaxDocument
constructor
A new instance of SaxDocument.
- #start_element_namespace(name, attrs = [], _prefix = nil, uri = nil, ns = []) ⇒ Object
Constructor Details
#initialize(base) ⇒ SaxDocument
Returns a new instance of SaxDocument.
14 15 16 17 18 19 20 21 |
# File 'lib/wsdl_mapper/deserializers/sax_document.rb', line 14 def initialize(base) @base = base @namespaces_stack = [] @buffer = '' @wrapper = nil @skipping = nil @current_frame = nil end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/wsdl_mapper/deserializers/sax_document.rb', line 8 def object @object end |
Instance Method Details
#cdata_block(text) ⇒ Object
95 96 97 |
# File 'lib/wsdl_mapper/deserializers/sax_document.rb', line 95 def cdata_block(text) @buffer << text end |
#characters(text) ⇒ Object
91 92 93 |
# File 'lib/wsdl_mapper/deserializers/sax_document.rb', line 91 def characters(text) @buffer << text end |
#end_document ⇒ Object
87 88 89 |
# File 'lib/wsdl_mapper/deserializers/sax_document.rb', line 87 def end_document @object = @last_frame.object end |
#end_element_namespace(name, _prefix = nil, uri = nil) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/wsdl_mapper/deserializers/sax_document.rb', line 61 def end_element_namespace(name, _prefix = nil, uri = nil) @namespaces_stack.pop if @wrapper == Name.get(uri, name) @wrapper = nil return end if @skipping # Check if the sub-tree-to-skip is at its end # TODO: edge case of nested same-element if @skipping == Name.get(uri, name) @skipping = nil return end # If we are skipping this sub-tree, just return return end @current_frame.text = @buffer @buffer = '' @last_frame = @current_frame @current_frame = @current_frame.parent if @current_frame @current_frame.children << @last_frame end @last_frame.end end |
#start_element_namespace(name, attrs = [], _prefix = nil, uri = nil, ns = []) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wsdl_mapper/deserializers/sax_document.rb', line 28 def start_element_namespace(name, attrs = [], _prefix = nil, uri = nil, ns = []) @buffer = '' if @skipping return end uri = inherit_element_namespace uri name = Name.get uri, name namespaces = Namespaces.for Hash[ns] @namespaces_stack << namespaces if @current_frame && @current_frame.mapping.wrapper?(name) @wrapper = name return end begin type_name = get_type_name name, attrs attrs = get_attributes type_name, attrs parent = @current_frame mapping = @base.get_type_mapping type_name @current_frame = Frame.new name, type_name, attrs, parent, namespaces, @base, mapping @current_frame.start rescue WsdlMapper::Deserializers::Errors::UnknownElementError => e if @base.skip_unknown_elements? @skipping = name return else raise e end end end |