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

root/trunk/lib/wsdl/import.rb

Revision 1824, 1.7 kB (checked in by nahi, 2 years ago)
  • Copyright notice updated. add '2000-2007' uniformly.
  • Property svn:eol-style set to native
  • Property svn:keywords set to author date id revision
Line 
1 # WSDL4R - WSDL import definition.
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 'wsdl/info'
10 require 'wsdl/importer'
11
12
13 module WSDL
14
15
16 class Import < Info
17   attr_reader :namespace
18   attr_reader :location
19   attr_reader :content
20
21   def initialize
22     super
23     @namespace = nil
24     @location = nil
25     @content = nil
26     @web_client = nil
27   end
28
29   def parse_element(element)
30     case element
31     when DocumentationName
32       o = Documentation.new
33       o
34     else
35       nil
36     end
37   end
38
39   def parse_attr(attr, value)
40     case attr
41     when NamespaceAttrName
42       @namespace = value.source
43       if @content
44         @content.targetnamespace = @namespace
45       end
46       @namespace
47     when LocationAttrName
48       @location = URI.parse(value.source)
49       if @location.relative? and !parent.location.nil? and
50           !parent.location.relative?
51         @location = parent.location + @location
52       end
53       if root.importedschema.key?(@location)
54         @content = root.importedschema[@location]
55       else
56         root.importedschema[@location] = nil      # placeholder
57         @content = import(@location)
58         if @content.is_a?(Definitions)
59           @content.root = root
60           if @namespace
61             @content.targetnamespace = @namespace
62           end
63         end
64         root.importedschema[@location] = @content
65       end
66       @location
67     else
68       nil
69     end
70   end
71
72 private
73
74   def import(location)
75     Importer.import(location, root)
76   end
77 end
78
79
80 end
Note: See TracBrowser for help on using the browser.