soap4r-ng 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +15 -0
  2. data/bin/wsdl2ruby.rb +140 -0
  3. data/bin/xsd2ruby.rb +92 -0
  4. data/lib/soap/attachment.rb +109 -0
  5. data/lib/soap/attrproxy.rb +35 -0
  6. data/lib/soap/baseData.rb +1095 -0
  7. data/lib/soap/element.rb +278 -0
  8. data/lib/soap/encodingstyle/aspDotNetHandler.rb +208 -0
  9. data/lib/soap/encodingstyle/handler.rb +121 -0
  10. data/lib/soap/encodingstyle/literalHandler.rb +196 -0
  11. data/lib/soap/encodingstyle/soapHandler.rb +560 -0
  12. data/lib/soap/filter.rb +14 -0
  13. data/lib/soap/filter/filterchain.rb +52 -0
  14. data/lib/soap/filter/handler.rb +32 -0
  15. data/lib/soap/filter/streamhandler.rb +30 -0
  16. data/lib/soap/generator.rb +299 -0
  17. data/lib/soap/header/handler.rb +62 -0
  18. data/lib/soap/header/handlerset.rb +71 -0
  19. data/lib/soap/header/mappinghandler.rb +48 -0
  20. data/lib/soap/header/simplehandler.rb +45 -0
  21. data/lib/soap/httpconfigloader.rb +140 -0
  22. data/lib/soap/mapping.rb +13 -0
  23. data/lib/soap/mapping/encodedregistry.rb +541 -0
  24. data/lib/soap/mapping/factory.rb +389 -0
  25. data/lib/soap/mapping/literalregistry.rb +392 -0
  26. data/lib/soap/mapping/mapping.rb +577 -0
  27. data/lib/soap/mapping/registry.rb +296 -0
  28. data/lib/soap/mapping/rubytypeFactory.rb +446 -0
  29. data/lib/soap/mapping/schemadefinition.rb +171 -0
  30. data/lib/soap/mapping/typeMap.rb +107 -0
  31. data/lib/soap/mapping/wsdlencodedregistry.rb +212 -0
  32. data/lib/soap/mapping/wsdlliteralregistry.rb +249 -0
  33. data/lib/soap/marshal.rb +60 -0
  34. data/lib/soap/mimemessage.rb +243 -0
  35. data/lib/soap/nestedexception.rb +43 -0
  36. data/lib/soap/netHttpClient.rb +242 -0
  37. data/lib/soap/ns.rb +39 -0
  38. data/lib/soap/parser.rb +253 -0
  39. data/lib/soap/processor.rb +67 -0
  40. data/lib/soap/property.rb +330 -0
  41. data/lib/soap/proxy.rb +15 -0
  42. data/lib/soap/rpc/cgistub.rb +249 -0
  43. data/lib/soap/rpc/driver.rb +222 -0
  44. data/lib/soap/rpc/element.rb +375 -0
  45. data/lib/soap/rpc/httpserver.rb +144 -0
  46. data/lib/soap/rpc/methodDef.rb +69 -0
  47. data/lib/soap/rpc/proxy.rb +573 -0
  48. data/lib/soap/rpc/router.rb +663 -0
  49. data/lib/soap/rpc/rpc.rb +26 -0
  50. data/lib/soap/rpc/soaplet.rb +201 -0
  51. data/lib/soap/rpc/standaloneServer.rb +44 -0
  52. data/lib/soap/soap.rb +154 -0
  53. data/lib/soap/streamHandler.rb +302 -0
  54. data/lib/soap/version.rb +9 -0
  55. data/lib/soap/wsdlDriver.rb +165 -0
  56. data/lib/wsdl/binding.rb +66 -0
  57. data/lib/wsdl/data.rb +65 -0
  58. data/lib/wsdl/definitions.rb +237 -0
  59. data/lib/wsdl/documentation.rb +33 -0
  60. data/lib/wsdl/import.rb +81 -0
  61. data/lib/wsdl/importer.rb +39 -0
  62. data/lib/wsdl/info.rb +51 -0
  63. data/lib/wsdl/message.rb +55 -0
  64. data/lib/wsdl/operation.rb +152 -0
  65. data/lib/wsdl/operationBinding.rb +241 -0
  66. data/lib/wsdl/param.rb +94 -0
  67. data/lib/wsdl/parser.rb +180 -0
  68. data/lib/wsdl/part.rb +53 -0
  69. data/lib/wsdl/port.rb +67 -0
  70. data/lib/wsdl/portType.rb +76 -0
  71. data/lib/wsdl/service.rb +62 -0
  72. data/lib/wsdl/soap/address.rb +41 -0
  73. data/lib/wsdl/soap/binding.rb +50 -0
  74. data/lib/wsdl/soap/body.rb +59 -0
  75. data/lib/wsdl/soap/cgiStubCreator.rb +93 -0
  76. data/lib/wsdl/soap/classDefCreator.rb +434 -0
  77. data/lib/wsdl/soap/classDefCreatorSupport.rb +241 -0
  78. data/lib/wsdl/soap/classNameCreator.rb +55 -0
  79. data/lib/wsdl/soap/clientSkeltonCreator.rb +107 -0
  80. data/lib/wsdl/soap/complexType.rb +174 -0
  81. data/lib/wsdl/soap/data.rb +43 -0
  82. data/lib/wsdl/soap/definitions.rb +201 -0
  83. data/lib/wsdl/soap/driverCreator.rb +121 -0
  84. data/lib/wsdl/soap/element.rb +34 -0
  85. data/lib/wsdl/soap/encodedMappingRegistryCreator.rb +74 -0
  86. data/lib/wsdl/soap/fault.rb +57 -0
  87. data/lib/wsdl/soap/header.rb +87 -0
  88. data/lib/wsdl/soap/headerfault.rb +57 -0
  89. data/lib/wsdl/soap/literalMappingRegistryCreator.rb +116 -0
  90. data/lib/wsdl/soap/mappingRegistryCreator.rb +59 -0
  91. data/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +377 -0
  92. data/lib/wsdl/soap/methodDefCreator.rb +200 -0
  93. data/lib/wsdl/soap/operation.rb +113 -0
  94. data/lib/wsdl/soap/servantSkeltonCreator.rb +92 -0
  95. data/lib/wsdl/soap/servletStubCreator.rb +105 -0
  96. data/lib/wsdl/soap/standaloneServerStubCreator.rb +101 -0
  97. data/lib/wsdl/soap/wsdl2ruby.rb +227 -0
  98. data/lib/wsdl/types.rb +45 -0
  99. data/lib/wsdl/wsdl.rb +25 -0
  100. data/lib/wsdl/xmlSchema/all.rb +25 -0
  101. data/lib/wsdl/xmlSchema/annotation.rb +35 -0
  102. data/lib/wsdl/xmlSchema/any.rb +62 -0
  103. data/lib/wsdl/xmlSchema/anyAttribute.rb +49 -0
  104. data/lib/wsdl/xmlSchema/attribute.rb +105 -0
  105. data/lib/wsdl/xmlSchema/attributeGroup.rb +69 -0
  106. data/lib/wsdl/xmlSchema/choice.rb +59 -0
  107. data/lib/wsdl/xmlSchema/complexContent.rb +98 -0
  108. data/lib/wsdl/xmlSchema/complexExtension.rb +120 -0
  109. data/lib/wsdl/xmlSchema/complexRestriction.rb +105 -0
  110. data/lib/wsdl/xmlSchema/complexType.rb +194 -0
  111. data/lib/wsdl/xmlSchema/content.rb +96 -0
  112. data/lib/wsdl/xmlSchema/data.rb +117 -0
  113. data/lib/wsdl/xmlSchema/element.rb +154 -0
  114. data/lib/wsdl/xmlSchema/enumeration.rb +37 -0
  115. data/lib/wsdl/xmlSchema/fractiondigits.rb +38 -0
  116. data/lib/wsdl/xmlSchema/group.rb +101 -0
  117. data/lib/wsdl/xmlSchema/import.rb +53 -0
  118. data/lib/wsdl/xmlSchema/importHandler.rb +45 -0
  119. data/lib/wsdl/xmlSchema/importer.rb +103 -0
  120. data/lib/wsdl/xmlSchema/include.rb +48 -0
  121. data/lib/wsdl/xmlSchema/length.rb +38 -0
  122. data/lib/wsdl/xmlSchema/list.rb +49 -0
  123. data/lib/wsdl/xmlSchema/maxexclusive.rb +38 -0
  124. data/lib/wsdl/xmlSchema/maxinclusive.rb +38 -0
  125. data/lib/wsdl/xmlSchema/maxlength.rb +38 -0
  126. data/lib/wsdl/xmlSchema/minexclusive.rb +38 -0
  127. data/lib/wsdl/xmlSchema/mininclusive.rb +38 -0
  128. data/lib/wsdl/xmlSchema/minlength.rb +38 -0
  129. data/lib/wsdl/xmlSchema/parser.rb +168 -0
  130. data/lib/wsdl/xmlSchema/pattern.rb +37 -0
  131. data/lib/wsdl/xmlSchema/ref.rb +34 -0
  132. data/lib/wsdl/xmlSchema/schema.rb +179 -0
  133. data/lib/wsdl/xmlSchema/sequence.rb +55 -0
  134. data/lib/wsdl/xmlSchema/simpleContent.rb +70 -0
  135. data/lib/wsdl/xmlSchema/simpleExtension.rb +63 -0
  136. data/lib/wsdl/xmlSchema/simpleRestriction.rb +133 -0
  137. data/lib/wsdl/xmlSchema/simpleType.rb +88 -0
  138. data/lib/wsdl/xmlSchema/totaldigits.rb +38 -0
  139. data/lib/wsdl/xmlSchema/union.rb +36 -0
  140. data/lib/wsdl/xmlSchema/unique.rb +35 -0
  141. data/lib/wsdl/xmlSchema/whitespace.rb +38 -0
  142. data/lib/wsdl/xmlSchema/xsd2ruby.rb +177 -0
  143. data/lib/xsd/charset.rb +190 -0
  144. data/lib/xsd/codegen.rb +13 -0
  145. data/lib/xsd/codegen/classdef.rb +209 -0
  146. data/lib/xsd/codegen/commentdef.rb +35 -0
  147. data/lib/xsd/codegen/gensupport.rb +277 -0
  148. data/lib/xsd/codegen/methoddef.rb +71 -0
  149. data/lib/xsd/codegen/moduledef.rb +209 -0
  150. data/lib/xsd/datatypes.rb +1465 -0
  151. data/lib/xsd/datatypes1999.rb +21 -0
  152. data/lib/xsd/iconvcharset.rb +33 -0
  153. data/lib/xsd/mapping.rb +69 -0
  154. data/lib/xsd/namedelements.rb +133 -0
  155. data/lib/xsd/ns.rb +183 -0
  156. data/lib/xsd/qname.rb +80 -0
  157. data/lib/xsd/xmlparser.rb +81 -0
  158. data/lib/xsd/xmlparser/libxmlparser.rb +135 -0
  159. data/lib/xsd/xmlparser/nokogiriparser.rb +58 -0
  160. data/lib/xsd/xmlparser/ogaparser.rb +63 -0
  161. data/lib/xsd/xmlparser/oxparser.rb +101 -0
  162. data/lib/xsd/xmlparser/parser.rb +101 -0
  163. data/lib/xsd/xmlparser/rexmlparser.rb +58 -0
  164. metadata +236 -0
@@ -0,0 +1,81 @@
1
+ # encoding: UTF-8
2
+ # XSD4R - XML Instance parser library.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+ require 'xsd/xmlparser/parser'
10
+
11
+ module XSD
12
+ module XMLParser
13
+
14
+ def create_parser(host, opt)
15
+ XSD::XMLParser::Parser.create_parser(host, opt)
16
+ end
17
+ module_function :create_parser
18
+
19
+ # $1 is necessary.
20
+ NSParseRegexp = Regexp.new('^xmlns:?(.*)$', nil)
21
+
22
+ def filter_ns(ns, attrs)
23
+ ns_updated = false
24
+ if attrs.nil? or attrs.empty?
25
+ return [ns, attrs]
26
+ end
27
+ newattrs = {}
28
+ attrs.each do |key, value|
29
+ if NSParseRegexp =~ key
30
+ unless ns_updated
31
+ ns = ns.clone_ns
32
+ ns_updated = true
33
+ end
34
+ # tag == '' means 'default namespace'
35
+ # value == '' means 'no default namespace'
36
+ tag = $1 || ''
37
+ ns.assign(value, tag)
38
+ else
39
+ newattrs[key] = value
40
+ end
41
+ end
42
+ return [ns, newattrs]
43
+ end
44
+ module_function :filter_ns
45
+
46
+ end
47
+ end
48
+
49
+
50
+ # Provide a means to CHOOSE a preferred XML Parser and loading-order, if multiple parser gems are available.
51
+ if ENV.has_key?('SOAP4R_PARSERS')
52
+ parser_list = ENV['SOAP4R_PARSERS'].to_s.split(',')
53
+ else
54
+ parser_list = [
55
+ 'oxparser', ## Uses its own C-Ruby Extension
56
+ 'nokogiri', ## Depends on LibXML2, LibXSLT, and ZLib
57
+ 'libxmlparser', ## Depends on LibXML2 ; Thread-Safe ; Somewhat Broken re: Namespaces
58
+ # ----- Pure-Ruby Parsers Below ---- #
59
+ 'ogaparser', ## Pure-Ruby
60
+ 'rexmlparser', ## Pure-Ruby, this is the reference implementation.
61
+ ]
62
+ end
63
+
64
+ # Try to load XML processor.
65
+ loaded = false
66
+ parser_list.each do |name|
67
+ begin
68
+ require "xsd/xmlparser/#{name}"
69
+ # XXX: for a workaround of rubygems' require inconsistency
70
+ # XXX: MUST BE REMOVED IN THE FUTURE
71
+ raise LoadError unless XSD::XMLParser.constants.find { |c|
72
+ c.to_s.downcase == name
73
+ }
74
+ loaded = true
75
+ break
76
+ rescue LoadError
77
+ end
78
+ end
79
+ unless loaded
80
+ raise RuntimeError.new("XML processor module not found.")
81
+ end
@@ -0,0 +1,135 @@
1
+ # encoding: UTF-8
2
+ # XSD4R - XMLParser XML parser library.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+ ### WIP, 2015-June-13:
10
+ ###
11
+ ### LibXML drops namespaces on Elements *AND* Attributes, which makes it impossible
12
+ ### to correctly associate Namespaces on Namespace-Declared Element Attributes when
13
+ ### more than one namespace exists.
14
+ ###
15
+ ### This issue is evident when you run test/soap/test_cookie.rb
16
+ ###
17
+
18
+ require 'libxml'
19
+
20
+ module XSD
21
+ module XMLParser
22
+
23
+
24
+ class LibXMLParser < XSD::XMLParser::Parser
25
+ include ::LibXML::XML::SaxParser::Callbacks
26
+
27
+ def do_parse(string_or_readable)
28
+ # string = string_or_readable.respond_to?(:read) ? string_or_readable.read : string_or_readable
29
+
30
+ @charset = 'utf-8'
31
+ string = StringIO.new(string_or_readable)
32
+ parser = LibXML::XML::SaxParser.io(string)
33
+ parser.callbacks = self
34
+ parser.parse
35
+ end
36
+
37
+ ENTITY_REF_MAP = {
38
+ 'lt' => '<',
39
+ 'gt' => '>',
40
+ 'amp' => '&',
41
+ 'quot' => '"',
42
+ 'apos' => '\''
43
+ }
44
+
45
+ #def on_internal_subset(name, external_id, system_id)
46
+ # nil
47
+ #end
48
+
49
+ #def on_is_standalone()
50
+ # nil
51
+ #end
52
+
53
+ #def on_has_internal_subset()
54
+ # nil
55
+ #end
56
+
57
+ #def on_has_external_subset()
58
+ # nil
59
+ #end
60
+
61
+ #def on_start_document()
62
+ # nil
63
+ #end
64
+
65
+ #def on_end_document()
66
+ # nil
67
+ #end
68
+
69
+ def on_start_element_ns (name, attr_hash, prefix, uri, namespaces)
70
+ prefixed_ns = attr_hash.merge(Hash[namespaces.map{|k,v| ["xmlns:#{k}",v]}])
71
+ if prefix.nil?
72
+ start_element(name, prefixed_ns)
73
+ else
74
+ start_element("#{prefix}:#{name}", prefixed_ns)
75
+ end
76
+ end
77
+
78
+ def on_end_element_ns (name, prefix, uri)
79
+ if prefix.nil?
80
+ end_element(name)
81
+ else
82
+ end_element("#{prefix}:#{name}")
83
+ end
84
+ end
85
+
86
+ def on_start_element (name, attr_hash)
87
+ # start_element(name, attr_hash)
88
+ end
89
+
90
+ def on_end_element(name)
91
+ # end_element(name)
92
+ end
93
+
94
+ def on_reference(name)
95
+ characters(ENTITY_REF_MAP[name])
96
+ end
97
+
98
+ def on_characters(chars)
99
+ characters(chars)
100
+ end
101
+
102
+ #def on_processing_instruction(target, data)
103
+ # nil
104
+ #end
105
+
106
+ #def on_comment(msg)
107
+ # nil
108
+ #end
109
+
110
+ def on_parser_warning(msg)
111
+ warn(msg)
112
+ end
113
+
114
+ def on_parser_error(msg)
115
+ raise ParseError.new(msg)
116
+ end
117
+
118
+ def on_parser_fatal_error(msg)
119
+ raise ParseError.new(msg)
120
+ end
121
+
122
+ def on_cdata_block(cdata)
123
+ characters(cdata)
124
+ end
125
+
126
+ def on_external_subset(name, external_id, system_id)
127
+ nil
128
+ end
129
+
130
+ add_factory(self)
131
+ end
132
+
133
+
134
+ end
135
+ end
@@ -0,0 +1,58 @@
1
+ # encoding: UTF-8
2
+ # XSD4R - Nokogiri XML parser library.
3
+ # Copyright (C) 2015 Laurence A. Lee <rubyjedi@gmail.com>
4
+
5
+ # This program is copyrighted free software by Laurence A. Lee. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+ require 'nokogiri'
10
+
11
+ module XSD
12
+ module XMLParser
13
+
14
+ class NokogiriParser < XSD::XMLParser::Parser
15
+ def do_parse(string_or_readable)
16
+ handler = NokoDocHandler.new(self)
17
+ parser = Nokogiri::XML::SAX::Parser.new(handler)
18
+ parser.parse(string_or_readable)
19
+ end
20
+
21
+ add_factory(self)
22
+ end
23
+
24
+
25
+ class NokoDocHandler < Nokogiri::XML::SAX::Document
26
+ def initialize(owner)
27
+ @owner = (owner)
28
+ end
29
+
30
+ def start_element(name,attrs)
31
+ attr_hash = Hash.new
32
+ attrs.each do |kv_array|
33
+ attr_hash[kv_array[0]] = kv_array[1]
34
+ end
35
+ @owner.send(:start_element, name, attr_hash)
36
+ end
37
+
38
+ def end_element(name)
39
+ @owner.send(:end_element, name)
40
+ end
41
+
42
+
43
+ def cdata_block(t)
44
+ @owner.send(:characters, t)
45
+ end
46
+
47
+ def characters(t)
48
+ @owner.send(:characters, t)
49
+ end
50
+
51
+ def comment(t)
52
+ @owner.send(:characters,t)
53
+ end
54
+ end
55
+
56
+
57
+ end
58
+ end
@@ -0,0 +1,63 @@
1
+ # encoding: UTF-8
2
+ # OgaParser XML parser library.
3
+ # Copyright (C) 2015 Laurence A. Lee <rubyjedi@gmail.com>.
4
+
5
+ # This program is copyrighted free software by Laurence A. Lee. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+ require 'pp'
10
+ require 'oga'
11
+
12
+
13
+ module XSD
14
+ module XMLParser
15
+
16
+ class OgaParser < XSD::XMLParser::Parser
17
+
18
+ def do_parse(string_or_readable)
19
+ # Oga::XML::SaxParser.new(self, string_or_readable)
20
+ Oga.sax_parse_xml(self, string_or_readable)
21
+ end
22
+
23
+
24
+ def on_element(namespace, name, attrs)
25
+ start_element(node_name(namespace, name), attrs)
26
+ end
27
+
28
+ def after_element(namespace, name)
29
+ end_element(node_name(namespace, name))
30
+ end
31
+
32
+
33
+ def on_cdata(t)
34
+ characters(t)
35
+ end
36
+
37
+ def on_comment(t)
38
+ characters(t)
39
+ end
40
+
41
+ def on_text(t)
42
+ characters(t)
43
+ end
44
+
45
+
46
+ def on_xml_decl(attr_hash)
47
+ # attr_hash['version'] = '1.0'; attr_hash['encoding'] = 'utf-8' (usually)
48
+ # $stderr.puts "XML Document #{attr_hash['version']} in #{attr_hash['encoding']} encoding."
49
+ end
50
+
51
+
52
+ private
53
+
54
+ def node_name(namespace, name)
55
+ namespace ? "#{namespace}:#{name}" : name.to_s
56
+ end
57
+
58
+ add_factory(self)
59
+
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,101 @@
1
+ # encoding: UTF-8
2
+ # XSD4R - OXParser XML parser library.
3
+ # Copyright (C) 2015 Laurence A. Lee <rubyjedi@gmail.com>.
4
+
5
+ # This program is copyrighted free software by Laurence A. Lee. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+ require 'ox'
10
+
11
+
12
+ module XSD
13
+ module XMLParser
14
+
15
+ class OxParser < XSD::XMLParser::Parser
16
+ def do_parse(string_or_readable)
17
+ @element_stack = []
18
+ begin
19
+ require 'htmlentities' # Used to unescape html-escaped chars, if available
20
+ @decoder = ::HTMLEntities.new(:expanded)
21
+ rescue LoadError
22
+ @decoder = nil
23
+ end
24
+
25
+ string = string_or_readable.respond_to?(:read) ? string_or_readable.read : StringIO.new(string_or_readable)
26
+ if @decoder.nil?
27
+ # Use the built-in conversion with Ox.
28
+ ::Ox.sax_parse(self, string, {:symbolize=> false, :convert_special=> true, :skip=> :skip_return} )
29
+ else
30
+ # Use HTMLEntities Decoder. Leave the special-character conversion alone and let HTMLEntities decode it for us.
31
+ ::Ox.sax_parse(self, string, {})
32
+ end
33
+ end
34
+
35
+
36
+ alias_method :base_start_element, :start_element
37
+ def start_element(n)
38
+ # $stderr.puts "OxParser.start_element INVOKED [#{n}]"
39
+ @element_stack.push n.to_s # Push the Element Name
40
+ @element_stack.push Hash.new
41
+ end
42
+
43
+ alias_method :base_end_element, :end_element
44
+ def end_element(n)
45
+ # $stderr.puts "OxParser.end_element INVOKED [#{n}]"
46
+ if @element_stack[-2].to_s == n.to_s
47
+ attr_hash = @element_stack.pop
48
+ attr_key = @element_stack.pop
49
+ else
50
+ $stderr.puts "!!!! OxParser.end_element FAILED TO FIND STACK PAIR [#{n}] IN STACK [#{PP.pp(@element_stack,'')}]"
51
+ end
52
+ base_end_element(n.to_s)
53
+ end
54
+
55
+
56
+ def text(t)
57
+ @decoder.nil? ? characters(t) : characters(@decoder.decode(t))
58
+ end
59
+
60
+ def cdata(t)
61
+ ## CAUTION: Ox Parser removes leading/trailing whitespace or blank lines. ##
62
+ ## This behavior is evident if you run the regression test:
63
+ ##
64
+ ## SOAP4R_PARSERS=oxparser bundle exec rake test:single test/soap/test_response_as_xml.rb
65
+ ##
66
+ @decoder.nil? ? characters(t) : characters(@decoder.decode(t))
67
+ end
68
+
69
+ def comment(t)
70
+ @decoder.nil? ? characters(t) : characters(@decoder.decode(t))
71
+ end
72
+
73
+
74
+ def instruct(n)
75
+ # Do nothing. This is the outer "XML" tag.
76
+ end
77
+
78
+ def end_instruct(n)
79
+ # Do nothing.
80
+ end
81
+
82
+
83
+ def attr(key,val)
84
+ return if @element_stack[-1].nil?
85
+
86
+ attr_hash = @element_stack[-1]
87
+ attr_hash[key.to_s] = val
88
+ end
89
+
90
+ def attrs_done
91
+ attr_hash = @element_stack[-1]
92
+ name = @element_stack[-2]
93
+
94
+ base_start_element(name, attr_hash) unless attr_hash.nil?
95
+ end
96
+
97
+ add_factory(self)
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,101 @@
1
+ # encoding: UTF-8
2
+ # XSD4R - XML Instance parser library.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'xsd/qname'
11
+ require 'xsd/ns'
12
+ require 'xsd/charset'
13
+
14
+
15
+ module XSD
16
+ module XMLParser
17
+
18
+
19
+ class Parser
20
+ class ParseError < Error; end
21
+ class FormatDecodeError < ParseError; end
22
+ class UnknownElementError < FormatDecodeError; end
23
+ class UnknownAttributeError < FormatDecodeError; end
24
+ class UnexpectedElementError < FormatDecodeError; end
25
+ class ElementConstraintError < FormatDecodeError; end
26
+ class ParserError < ParseError; end
27
+
28
+ @@parser_factory = nil
29
+
30
+ def self.factory
31
+ @@parser_factory
32
+ end
33
+
34
+ def self.create_parser(host, opt = {})
35
+ unless @@parser_factory
36
+ raise ParserError.new("illegal XML parser configuration")
37
+ end
38
+ @@parser_factory.new(host, opt)
39
+ end
40
+
41
+ def self.add_factory(factory)
42
+ if $DEBUG
43
+ puts "Set #{ factory } as XML processor."
44
+ end
45
+ @@parser_factory = factory
46
+ end
47
+
48
+ public
49
+
50
+ attr_accessor :charset
51
+
52
+ def initialize(host, opt = {})
53
+ @host = host
54
+ @charset = opt[:charset] || nil
55
+ end
56
+
57
+ def parse(string_or_readable)
58
+ @textbuf = ''
59
+ prologue
60
+ do_parse(string_or_readable)
61
+ epilogue
62
+ end
63
+
64
+ private
65
+
66
+ def do_parse(string_or_readable)
67
+ raise ParserError.new(
68
+ 'Method do_parse must be defined in derived class.')
69
+ end
70
+
71
+ def start_element(name, attrs)
72
+ @host.start_element(name, attrs)
73
+ end
74
+
75
+ def characters(text)
76
+ @host.characters(text)
77
+ end
78
+
79
+ def end_element(name)
80
+ @host.end_element(name)
81
+ end
82
+
83
+ def prologue
84
+ end
85
+
86
+ def epilogue
87
+ end
88
+
89
+ def xmldecl_encoding=(charset)
90
+ if @charset.nil?
91
+ @charset = charset
92
+ else
93
+ # Definition in a stream (like HTTP) has a priority.
94
+ p "encoding definition: #{ charset } is ignored." if $DEBUG
95
+ end
96
+ end
97
+ end
98
+
99
+
100
+ end
101
+ end