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

Changeset 1488

Show
Ignore:
Timestamp:
04/16/05 19:21:11 (4 years ago)
Author:
nahi
Message:

allow xsd:include or xsd:import with relative URL schemaLocation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/netHttpClient.rb

    r1383 r1488  
    9797 
    9898  def get_content(url, header = {}) 
    99     url = URI.parse(url) 
     99    unless url.is_a?(URI) 
     100      url = URI.parse(url) 
     101    end 
    100102    extra = header.dup 
    101103    extra['User-Agent'] = @agent if @agent 
  • trunk/lib/wsdl/definitions.rb

    r1416 r1488  
    1919  attr_reader :imports 
    2020 
     21  attr_accessor :location 
     22 
    2123  def initialize 
    2224    super 
    2325    @name = nil 
    2426    @targetnamespace = nil 
     27    @location = nil 
    2528    @types = nil 
    2629    @imports = [] 
  • trunk/lib/wsdl/import.rb

    r1369 r1488  
    4646      @namespace 
    4747    when LocationAttrName 
    48       @location = value.source 
     48      @location = URI.parse(value.source) 
     49      if @location.relative? 
     50        @location = parent.location + @location 
     51      end 
    4952      @content = import(@location) 
    5053      if @content.is_a?(Definitions) 
  • trunk/lib/wsdl/importer.rb

    r1422 r1488  
    2121private 
    2222 
    23   def parse(content
     23  def parse(content, location
    2424    begin 
    25       WSDL::Parser.new({}).parse(content) 
     25      WSDL::Parser.new({:location => location}).parse(content) 
    2626    rescue WSDL::Parser::ParseError 
    27       super(content
     27      super(content, location
    2828    end 
    2929  end 
  • trunk/lib/wsdl/parser.rb

    r1421 r1488  
    5555    @lastnode = nil 
    5656    @ignored = {} 
     57    @location = opt[:location] 
    5758  end 
    5859 
     
    112113      if elename == DefinitionsName 
    113114        o = Definitions.parse_element(elename) 
     115        o.location = @location 
     116        o 
    114117      else 
    115118        raise UnknownElementError.new("unknown element: #{elename}") 
  • trunk/lib/wsdl/xmlSchema/import.rb

    r1475 r1488  
    3636      @namespace = value.source 
    3737    when SchemaLocationAttrName 
    38       @schemalocation = value.source 
     38      @schemalocation = URI.parse(value.source) 
     39      if @schemalocation.relative? 
     40        @schemalocation = parent.location + @schemalocation 
     41      end 
    3942      @content = import(@schemalocation) 
    4043      @schemalocation 
  • trunk/lib/wsdl/xmlSchema/importer.rb

    r1422 r1488  
    2525 
    2626  def import(location) 
    27     parse(fetch(location)) 
     27    unless location.is_a?(URI) 
     28      location = URI.parse(location) 
     29    end 
     30    content = parse(fetch(location), location) 
     31    content.location = location 
     32    content 
    2833  end 
    2934 
    3035private 
    3136 
    32   def parse(content
    33     WSDL::XMLSchema::Parser.new({}).parse(content) 
     37  def parse(content, location
     38    WSDL::XMLSchema::Parser.new({:location => location}).parse(content) 
    3439  end 
    3540 
     
    3742    STDERR.puts("importing: #{location}") if $DEBUG 
    3843    content = nil 
    39     if FileTest.exist?(location) 
    40       content = File.open(location).read 
     44    if location.scheme == 'file' or 
     45        (location.relative? and FileTest.exist?(location.path)) 
     46      content = File.open(location.path).read 
    4147    else 
    4248      client = web_client.new(nil, "WSDL4R") 
  • trunk/lib/wsdl/xmlSchema/parser.rb

    r1483 r1488  
    5353    @lastnode = nil 
    5454    @ignored = {} 
     55    @location = opt[:location] 
    5556  end 
    5657 
     
    110111      if elename == SchemaName 
    111112        o = Schema.parse_element(elename) 
     113        o.location = @location 
     114        o 
    112115      else 
    113116        raise UnknownElementError.new("unknown element: #{elename}") 
  • trunk/lib/wsdl/xmlSchema/schema.rb

    r1475 r1488  
    2525  attr_accessor :elementformdefault 
    2626 
     27  attr_accessor :location 
     28 
    2729  def initialize 
    2830    super 
     
    3436    @imports = [] 
    3537    @elementformdefault = "qualified" 
     38    @location = nil 
    3639    @root = self 
    3740  end 
     
    4144    when ImportName 
    4245      o = Import.new 
     46      @imports << o 
     47      o 
     48    when IncludeName 
     49      o = Include.new 
    4350      @imports << o 
    4451      o 
  • trunk/lib/wsdl/xmlSchema/xsd2ruby.rb

    r1437 r1488  
    8787 
    8888  def create_classname(xsd) 
    89     name = xsd.targetnamespace.scan(/[a-zA-Z0-9]+$/)[0] 
     89    name = nil 
     90    if xsd.targetnamespace 
     91      name = xsd.targetnamespace.scan(/[a-zA-Z0-9]+$/)[0] 
     92    end 
    9093    if name.nil? 
    9194      'default'