summaryrefslogtreecommitdiff
path: root/lib/wsdl/xmlSchema/import.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wsdl/xmlSchema/import.rb')
-rw-r--r--lib/wsdl/xmlSchema/import.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/wsdl/xmlSchema/import.rb b/lib/wsdl/xmlSchema/import.rb
index e65641330d..d3487af934 100644
--- a/lib/wsdl/xmlSchema/import.rb
+++ b/lib/wsdl/xmlSchema/import.rb
@@ -1,5 +1,5 @@
# WSDL4R - XMLSchema import definition.
-# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
# redistribute it and/or modify it under the same terms of Ruby's license;
@@ -7,6 +7,7 @@
require 'wsdl/info'
+require 'wsdl/xmlSchema/importer'
module WSDL
@@ -16,11 +17,13 @@ module XMLSchema
class Import < Info
attr_reader :namespace
attr_reader :schemalocation
+ attr_reader :content
def initialize
super
@namespace = nil
@schemalocation = nil
+ @content = nil
end
def parse_element(element)
@@ -32,11 +35,29 @@ class Import < Info
when NamespaceAttrName
@namespace = value.source
when SchemaLocationAttrName
- @schemalocation = value.source
+ @schemalocation = URI.parse(value.source)
+ if @schemalocation.relative? and !parent.location.nil? and
+ !parent.location.relative?
+ @schemalocation = parent.location + @schemalocation
+ end
+ if root.importedschema.key?(@schemalocation)
+ @content = root.importedschema[@schemalocation]
+ else
+ root.importedschema[@schemalocation] = nil # placeholder
+ @content = import(@schemalocation)
+ root.importedschema[@schemalocation] = @content
+ end
+ @schemalocation
else
nil
end
end
+
+private
+
+ def import(location)
+ Importer.import(location, root)
+ end
end