Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/trunk/lib/soap/encodingstyle/handler.rb

Revision 1975, 2.1 kB (checked in by nahi, 1 year ago)
  • XML attribute must not be affected by default namespace. closes #430.
  • Property svn:eol-style set to native
  • Property svn:keywords set to author date id revision
Line 
1 # SOAP4R - EncodingStyle handler library
2 # Copyright (C) 2000-2007  NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
3
4 # This program is copyrighted free software by NAKAMURA, Hiroshi.  You can
5 # redistribute it and/or modify it under the same terms of Ruby's license;
6 # either the dual license version in 2003, or any later version.
7
8
9 require 'soap/soap'
10 require 'soap/baseData'
11 require 'soap/element'
12
13
14 module SOAP
15 module EncodingStyle
16
17
18 class Handler
19   @@handlers = {}
20
21   class EncodingStyleError < Error; end
22
23   class << self
24     def uri
25       self::Namespace
26     end
27
28     def handler(uri)
29       @@handlers[uri]
30     end
31
32     def each
33       @@handlers.each do |key, value|
34         yield(value)
35       end
36     end
37
38   private
39
40     def add_handler
41       @@handlers[self.uri] = self
42     end
43   end
44
45   attr_reader :charset
46   attr_accessor :generate_explicit_type
47   def decode_typemap=(definedtypes)
48     @decode_typemap = definedtypes
49   end
50
51   def initialize(charset)
52     @charset = charset
53     @generate_explicit_type = true
54     @decode_typemap = nil
55   end
56
57   ###
58   ## encode interface.
59   #
60   # Returns a XML instance as a string.
61   def encode_data(generator, ns, data, parent)
62     raise NotImplementError
63   end
64
65   def encode_data_end(generator, ns, data, parent)
66     raise NotImplementError
67   end
68
69   def encode_prologue
70   end
71
72   def encode_epilogue
73   end
74
75   ###
76   ## decode interface.
77   #
78   # Returns SOAP/OM data.
79   def decode_tag(ns, name, attrs, parent)
80     raise NotImplementError
81   end
82
83   def decode_tag_end(ns, name)
84     raise NotImplementError
85   end
86
87   def decode_text(ns, text)
88     raise NotImplementError
89   end
90
91   def decode_prologue
92   end
93
94   def decode_epilogue
95   end
96
97   def encode_attr_key(attrs, ns, qname)
98     if qname.namespace.nil?
99       qname.name
100     else
101       unless ns.assigned_as_tagged?(qname.namespace)
102         Generator.assign_ns!(attrs, ns, qname.namespace)
103       end
104       ns.name_attr(qname)
105     end
106   end
107
108   def encode_qname(attrs, ns, qname)
109     if qname.namespace.nil?
110       qname.name
111     else
112       Generator.assign_ns(attrs, ns, qname.namespace)
113       ns.name(qname)
114     end
115   end
116 end
117
118
119 end
120 end
Note: See TracBrowser for help on using the browser.