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

Changeset 1643

Show
Ignore:
Timestamp:
10/16/05 21:31:00 (3 years ago)
Author:
nahi
Message:

support for <complexContent> + <extension>. closes #72.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/wsdl/parser.rb

    r1552 r1643  
    126126        o = parent.parse_element(elename) 
    127127      end 
    128       unless o 
     128      if o.nil? 
    129129        unless @ignored.key?(elename) 
    130130          warn("ignored element: #{elename}") 
     
    141141      value_ele = ns.parse(value, true) 
    142142      value_ele.source = value  # for recovery; value may not be a QName 
    143       unless o.parse_attr(attr_ele, value_ele) 
     143      if o.parse_attr(attr_ele, value_ele).nil? 
    144144        unless @ignored.key?(attr_ele) 
    145145          warn("ignored attr: #{attr_ele}") 
  • trunk/lib/wsdl/soap/complexType.rb

    r1582 r1643  
    2222  def check_type 
    2323    if content 
    24       if attributes.empty? and 
    25           content.elements.size == 1 and content.elements[0].maxoccurs != '1' 
     24      e = elements 
     25      if attributes.empty? and e.size == 1 and e[0].maxoccurs != '1' 
    2626        if name == ::SOAP::Mapping::MapQName 
    2727          :TYPE_MAP 
     
    3333      end 
    3434    elsif complexcontent 
    35       if complexcontent.base == ::SOAP::ValueArrayName 
    36         :TYPE_ARRAY 
    37       else 
    38         complexcontent.basetype.check_type 
    39       end 
     35      complexcontent.check_type 
    4036    elsif simplecontent 
    4137      :TYPE_SIMPLE 
     
    8278      end 
    8379    when :TYPE_ARRAY 
    84       if content.elements.size == 1 
    85         ele = content.elements[0] 
     80      e = elements 
     81      if e.size == 1 
     82        ele = e[0] 
    8683      else 
    8784        raise RuntimeError.new("Assert: must not reach.") 
     
    10198    end 
    10299    if complexcontent 
    103       complexcontent.attributes.each do |attribute| 
    104         if attribute.ref == ::SOAP::AttrArrayTypeName 
    105           return attribute.arytype 
    106         end 
     100      if complexcontent.restriction 
     101        complexcontent.restriction.attributes.each do |attribute| 
     102          if attribute.ref == ::SOAP::AttrArrayTypeName 
     103            return attribute.arytype 
     104          end 
     105        end 
    107106      end 
    108       if check_array_content(complexcontent.content) 
    109         return element_simpletype(complexcontent.content.elements[0]) 
    110       end 
    111     elsif check_array_content(content) 
    112       return element_simpletype(content.elements[0]) 
     107    end 
     108    if check_array_content 
     109      return element_simpletype(elements[0]) 
    113110    end 
    114111    raise RuntimeError.new("Assert: Unknown array definition.") 
     
    119116      raise RuntimeError.new("Assert: not for array") 
    120117    end 
    121     if complexcontent 
    122       if check_array_content(complexcontent.content) 
    123         return complexcontent.content.elements[0] 
    124       end 
    125     elsif check_array_content(content) 
    126       return content.elements[0] 
     118    if check_array_content 
     119      return elements[0] 
    127120    end 
    128121    nil # use default item name 
     
    141134  end 
    142135 
    143   def check_array_content(content) 
    144     content and content.elements.size == 1 and 
    145       content.elements[0].maxoccurs != '1' 
     136  def check_array_content 
     137    e = elements 
     138    e.size == 1 and e[0].maxoccurs != '1' 
     139    # content and content.elements.size == 1 and 
     140    #   content.elements[0].maxoccurs != '1' 
    146141  end 
    147142 
  • trunk/lib/wsdl/soap/definitions.rb

    r1520 r1643  
    2727    type = XMLSchema::ComplexType.new(::SOAP::ValueArrayName) 
    2828    type.complexcontent = XMLSchema::ComplexContent.new 
    29     type.complexcontent.base = ::SOAP::ValueArrayName 
     29    type.complexcontent.restriction = XMLSchema::ComplexRestriction.new 
     30    type.complexcontent.restriction.base = ::SOAP::ValueArrayName 
    3031    attr = XMLSchema::Attribute.new 
    3132    attr.ref = ::SOAP::AttrArrayTypeName 
     
    3334    anytype.name += '[]' 
    3435    attr.arytype = anytype 
    35     type.complexcontent.attributes << attr 
     36    type.complexcontent.restriction.attributes << attr 
    3637    type 
    3738  end 
  • trunk/lib/wsdl/xmlSchema/all.rb

    r1580 r1643  
    11# WSDL4R - XMLSchema complexType definition for WSDL. 
    2 # Copyright (C) 2002, 2003  NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 
     2# Copyright (C) 2002, 2003, 2005  NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 
    33 
    44# This program is copyrighted free software by NAKAMURA, Hiroshi.  You can 
     
    2323    @minoccurs = '1' 
    2424    @maxoccurs = '1' 
    25     @elements = [] 
     25    @elements = XSD::NamedElements.new 
    2626  end 
    2727 
  • trunk/lib/wsdl/xmlSchema/choice.rb

    r1580 r1643  
    11# WSDL4R - XMLSchema complexType definition for WSDL. 
    2 # Copyright (C) 2002, 2003  NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 
     2# Copyright (C) 2002, 2003, 2005  NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 
    33 
    44# This program is copyrighted free software by NAKAMURA, Hiroshi.  You can 
     
    2323    @minoccurs = '1' 
    2424    @maxoccurs = '1' 
    25     @elements = [] 
     25    @elements = XSD::NamedElements.new 
    2626  end 
    2727 
  • trunk/lib/wsdl/xmlSchema/complexContent.rb

    r1629 r1643  
    1616 
    1717class ComplexContent < Info 
    18   attr_accessor :base 
    19   attr_reader :derivetype 
    20   attr_reader :content 
    21   attr_reader :attributes 
     18  attr_accessor :restriction 
     19  attr_accessor :extension 
    2220 
    2321  def initialize 
    2422    super 
    25     @base = nil 
    26     @derivetype = nil 
    27     @content = nil 
    28     @attributes = XSD::NamedElements.new 
    29     @basetype = nil 
     23    @restriction = nil 
     24    @extension = nil 
    3025  end 
    3126 
     
    3833  end 
    3934 
    40   def basetype 
    41     @basetype ||= root.collect_complextypes[@base] 
     35  def content 
     36    @extension || @restriction 
     37  end 
     38 
     39  def elements 
     40    content.elements 
     41  end 
     42 
     43  def attributes 
     44    content.attributes 
     45  end 
     46 
     47  def check_type 
     48    if content 
     49      content.check_type 
     50    else 
     51      raise ArgumentError.new("incomplete complexContent") 
     52    end 
    4253  end 
    4354 
    4455  def parse_element(element) 
    4556    case element 
    46     when RestrictionName, ExtensionName 
    47       @derivetype = element.name 
    48       self 
    49     when AllName 
    50       if @derivetype.nil? 
    51         raise Parser::ElementConstraintError.new("base attr not found.") 
    52       end 
    53       @content = All.new 
    54       @content 
    55     when SequenceName 
    56       if @derivetype.nil? 
    57         raise Parser::ElementConstraintError.new("base attr not found.") 
    58       end 
    59       @content = Sequence.new 
    60       @content 
    61     when ChoiceName 
    62       if @derivetype.nil? 
    63         raise Parser::ElementConstraintError.new("base attr not found.") 
    64       end 
    65       @content = Choice.new 
    66       @content 
    67     when AttributeName 
    68       if @derivetype.nil? 
    69         raise Parser::ElementConstraintError.new("base attr not found.") 
    70       end 
    71       o = Attribute.new 
    72       @attributes << o 
    73       o 
     57    when RestrictionName 
     58      raise ArgumentError.new("incomplete complexContent") if content 
     59      @restriction = ComplexRestriction.new 
     60    when ExtensionName 
     61      raise ArgumentError.new("incomplete complexContent") if content 
     62      @extension = ComplexExtension.new 
    7463    end 
    7564  end 
    7665 
    7766  def parse_attr(attr, value) 
    78     if @derivetype.nil? 
    79       return nil 
    80     end 
    81     case attr 
    82     when BaseAttrName 
    83       @base = value 
    84     else 
    85       nil 
    86     end 
     67    nil 
    8768  end 
    8869end 
  • trunk/lib/wsdl/xmlSchema/complexType.rb

    r1618 r1643  
    2424  attr_accessor :final 
    2525  attr_accessor :mixed 
    26   attr_reader :attributes 
    2726 
    2827  def initialize(name = nil) 
     
    4645    parent.elementformdefault 
    4746  end 
     47 
     48  def elements 
     49    c = @complexcontent || @content 
     50    c ? c.elements : nil 
     51  end 
     52 
     53  def attributes 
     54    if @complexcontent 
     55      @complexcontent.attributes 
     56    else 
     57      @attributes 
     58    end 
     59  end 
    4860  
    4961  AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName) 
    5062  def each_element 
    51     if content 
    52       content.elements.each do |element| 
     63    if e = elements 
     64      e.each do |element| 
    5365        if element.is_a?(Any) 
    5466          yield(AnyAsElement) 
     
    6173 
    6274  def find_element(name) 
    63     if content 
    64       content.elements.each do |element| 
     75    if e = elements 
     76      e.each do |element| 
    6577        if element.is_a?(Any) 
    6678          return AnyAsElement if name == AnyAsElement.name 
     
    7486 
    7587  def find_element_by_name(name) 
    76     if content 
    77       content.elements.each do |element| 
     88    if e = elements 
     89      e.each do |element| 
    7890        if element.is_a?(Any) 
    7991          return AnyAsElement if name == AnyAsElement.name.name 
  • trunk/lib/wsdl/xmlSchema/data.rb

    r1520 r1643  
    1717require 'wsdl/xmlSchema/complexType' 
    1818require 'wsdl/xmlSchema/complexContent' 
     19require 'wsdl/xmlSchema/complexRestriction' 
     20require 'wsdl/xmlSchema/complexExtension' 
    1921require 'wsdl/xmlSchema/simpleContent' 
    2022require 'wsdl/xmlSchema/any' 
  • trunk/lib/wsdl/xmlSchema/parser.rb

    r1552 r1643  
    124124        o = parent.parse_element(elename) 
    125125      end 
    126       unless o 
     126      if o.nil? 
    127127        unless @ignored.key?(elename) 
    128128          warn("ignored element: #{elename} of #{parent.class}") 
     
    142142        o.id = value_ele 
    143143      else 
    144         unless o.parse_attr(attr_ele, value_ele) 
     144        if o.parse_attr(attr_ele, value_ele).nil? 
    145145          unless @ignored.key?(attr_ele) 
    146146            warn("ignored attr: #{attr_ele}") 
  • trunk/lib/wsdl/xmlSchema/sequence.rb

    r1580 r1643  
    11# WSDL4R - XMLSchema complexType definition for WSDL. 
    2 # Copyright (C) 2002, 2003  NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 
     2# Copyright (C) 2002, 2003, 2005  NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 
    33 
    44# This program is copyrighted free software by NAKAMURA, Hiroshi.  You can 
     
    2323    @minoccurs = '1' 
    2424    @maxoccurs = '1' 
    25     @elements = [] 
     25    @elements = XSD::NamedElements.new 
    2626  end 
    2727 
  • trunk/test/wsdl/complexcontent/test_echo.rb

    r1637 r1643  
    8383    @client.endpoint_url = "http://localhost:#{Port}/" 
    8484    @client.wiredump_dev = STDOUT if $DEBUG 
    85     assert_instance_of(Echo, @client.echo(Echo.new(Derived.new))) 
     85    d = Derived.new 
     86    d.Name = "NaHi" 
     87    assert_instance_of(Echo, @client.echo(Echo.new(d))) 
    8688  end 
    8789end