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

Changeset 1917

Show
Ignore:
Timestamp:
08/13/07 00:20:00 (1 year ago)
Author:
nahi
Message:
  • added support for attributeGroup.
Files:

Legend:

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

    r1906 r1917  
    5252 
    5353  def collect_attributes 
    54     result = XSD::NamedElements.new 
    55     if @types 
    56       @types.schemas.each do |schema| 
    57         result.concat(schema.collect_attributes) 
    58       end 
    59     end 
    60     @imports.each do |import| 
    61       result.concat(import.content.collect_attributes) 
    62     end 
    63     result 
     54    collect_imports(:collect_attributes) 
    6455  end 
    6556 
    6657  def collect_modelgroups 
    67     result = XSD::NamedElements.new 
    68     if @types 
    69       @types.schemas.each do |schema| 
    70         result.concat(schema.collect_modelgroups) 
    71       end 
    72     end 
    73     @imports.each do |import| 
    74       result.concat(import.content.collect_modelgroups) 
    75     end 
    76     result 
     58    collect_imports(:collect_modelgroups) 
     59  end 
     60 
     61  def collect_attributegroups 
     62    collect_imports(:collect_attributegroups) 
    7763  end 
    7864 
    7965  def collect_elements 
    80     result = XSD::NamedElements.new 
    81     if @types 
    82       @types.schemas.each do |schema| 
    83         result.concat(schema.collect_elements) 
    84       end 
    85     end 
    86     @imports.each do |import| 
    87       result.concat(import.content.collect_elements) 
    88     end 
    89     result 
     66    collect_imports(:collect_elements) 
    9067  end 
    9168 
    9269  def collect_complextypes 
    93     result = @anontypes.dup 
    94     if @types 
    95       @types.schemas.each do |schema| 
    96         result.concat(schema.collect_complextypes) 
    97       end 
    98     end 
    99     @imports.each do |import| 
    100       result.concat(import.content.collect_complextypes) 
    101     end 
    102     result 
     70    result = collect_imports(:collect_complextypes) 
     71    @anontypes.dup.concat(result) 
    10372  end 
    10473 
    10574  def collect_simpletypes 
    106     result = XSD::NamedElements.new 
    107     if @types 
    108       @types.schemas.each do |schema| 
    109         result.concat(schema.collect_simpletypes) 
    110       end 
    111     end 
    112     @imports.each do |import| 
    113       result.concat(import.content.collect_simpletypes) 
    114     end 
    115     result 
     75    collect_imports(:collect_simpletypes) 
    11676  end 
    11777 
     
    258218private 
    259219 
     220  def collect_imports(method) 
     221    result = XSD::NamedElements.new 
     222    if @types 
     223      @types.schemas.each do |schema| 
     224        result.concat(schema.send(method)) 
     225      end 
     226    end 
     227    @imports.each do |import| 
     228      result.concat(import.content.send(method)) 
     229    end 
     230    result 
     231  end 
     232 
    260233end 
    261234 
  • trunk/lib/wsdl/xmlSchema/complexExtension.rb

    r1905 r1917  
    1818  attr_accessor :base 
    1919  attr_reader :content 
    20   attr_accessor :anyattribute 
    2120 
    2221  def initialize 
     
    2625    @content = nil 
    2726    @attributes = XSD::NamedElements.new 
    28     @anyattribute = nil 
    2927  end 
    3028 
     
    8886      @attributes << o 
    8987      o 
     88    when AttributeGroupName 
     89      o = AttributeGroup.new 
     90      @attributes << o 
     91      o 
    9092    when AnyAttributeName 
    91       @anyattribute = AnyAttribute.new 
     93      o = AnyAttribute.new 
     94      @attributes << o 
     95      o 
    9296    end 
    9397  end 
  • trunk/lib/wsdl/xmlSchema/complexRestriction.rb

    r1905 r1917  
    1919  attr_reader :content 
    2020  attr_reader :attributes 
    21   attr_accessor :anyattribute 
    2221 
    2322  def initialize 
     
    2726    @content = nil 
    2827    @attributes = XSD::NamedElements.new 
    29     @anyattribute = nil 
    3028  end 
    3129 
     
    7775      @attributes << o 
    7876      o 
     77    when AttributeGroupName 
     78      o = AttributeGroup.new 
     79      @attributes << o 
     80      o 
    7981    when AnyAttributeName 
    80       @anyattribute = AnyAttribute.new 
     82      o = AnyAttribute.new 
     83      @attributes << o 
     84      o 
    8185    end 
    8286  end 
  • trunk/lib/wsdl/xmlSchema/complexType.rb

    r1906 r1917  
    2424  attr_accessor :mixed 
    2525  attr_accessor :abstract 
    26   attr_accessor :anyattribute 
    2726 
    2827  def initialize(name = nil) 
     
    3635    @abstract = false 
    3736    @attributes = XSD::NamedElements.new 
    38     @anyattribute = nil 
    3937  end 
    4038 
     
    7472 
    7573  def attributes 
     74    attrs = nil 
    7675    if @complexcontent 
    77       @complexcontent.attributes + @attributes 
     76      attrs = @complexcontent.attributes + @attributes 
    7877    elsif @simplecontent 
    79       @simplecontent.attributes + @attributes 
     78      attrs = @simplecontent.attributes + @attributes 
    8079    else 
    81       @attributes 
     80      attrs = @attributes 
    8281    end 
     82    found = XSD::NamedElements.new 
     83    attrs.each do |attr| 
     84      case attr 
     85      when Attribute 
     86        found << attr 
     87      when AttributeGroup 
     88        if attr.attributes 
     89          found.concat(attr.attributes) 
     90        end 
     91      when AnyAttribute 
     92        # ignored 
     93      else 
     94        warn("unknown attribute: #{attr}") 
     95      end 
     96    end 
     97    found 
    8398  end 
    8499 
     
    139154      @attributes << o 
    140155      o 
     156    when AttributeGroupName 
     157      o = AttributeGroup.new 
     158      @attributes << o 
     159      o 
    141160    when AnyAttributeName 
    142       @anyattribute = AnyAttribute.new 
     161      o = AnyAttribute.new 
     162      @attributes << o 
     163      o 
    143164    else 
    144165      nil 
  • trunk/lib/wsdl/xmlSchema/data.rb

    r1906 r1917  
    3131require 'wsdl/xmlSchema/unique' 
    3232require 'wsdl/xmlSchema/group' 
     33require 'wsdl/xmlSchema/attributeGroup' 
    3334 
    3435require 'wsdl/xmlSchema/length' 
     
    5455AnyAttributeName = XSD::QName.new(XSD::Namespace, 'anyAttribute') 
    5556AttributeName = XSD::QName.new(XSD::Namespace, 'attribute') 
     57AttributeGroupName = XSD::QName.new(XSD::Namespace, 'attributeGroup') 
    5658ChoiceName = XSD::QName.new(XSD::Namespace, 'choice') 
    5759ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent') 
  • trunk/lib/wsdl/xmlSchema/group.rb

    r1906 r1917  
    8484    case attr 
    8585    when NameAttrName 
    86       # namespace may be nil 
    87       if directelement? or elementform == 'qualified' 
    88         @name = XSD::QName.new(targetnamespace, value.source) 
    89       else 
    90         @name = XSD::QName.new(nil, value.source) 
    91       end 
     86      @name = XSD::QName.new(targetnamespace, value.source) 
    9287    when RefAttrName 
    9388      @ref = value 
     
    117112    end 
    118113  end 
    119  
    120 private 
    121  
    122   def directelement? 
    123     parent.is_a?(Schema) 
    124   end 
    125114end 
    126115 
  • trunk/lib/wsdl/xmlSchema/schema.rb

    r1906 r1917  
    2222  attr_reader :attributes 
    2323  attr_reader :modelgroups 
     24  attr_reader :attributegroups 
    2425  attr_reader :imports 
    2526  attr_accessor :attributeformdefault 
     
    3738    @attributes = XSD::NamedElements.new 
    3839    @modelgroups = XSD::NamedElements.new 
     40    @attributegroups = XSD::NamedElements.new 
    3941    @imports = [] 
    4042    @attributeformdefault = "unqualified" 
     
    8587      @modelgroups << o 
    8688      o 
     89    when AttributeGroupName 
     90      o = AttributeGroup.new 
     91      @attributegroups << o 
     92      o 
    8793    else 
    8894      nil 
     
    119125    @imports.each do |import| 
    120126      result.concat(import.content.collect_modelgroups) if import.content 
     127    end 
     128    result 
     129  end 
     130 
     131  def collect_attributegroups 
     132    result = XSD::NamedElements.new 
     133    result.concat(@attributegroups) 
     134    @imports.each do |import| 
     135      result.concat(import.content.collect_attributegroups) if import.content 
    121136    end 
    122137    result 
  • trunk/lib/wsdl/xmlSchema/simpleExtension.rb

    r1905 r1917  
    1818  attr_reader :base 
    1919  attr_reader :attributes 
    20   attr_accessor :anyattribute 
    2120 
    2221  def initialize 
     
    2423    @base = nil 
    2524    @attributes = XSD::NamedElements.new 
    26     @anyattribute = nil 
    2725  end 
    2826 
     
    4139      @attributes << o 
    4240      o 
     41    when AttributeGroupName 
     42      o = AttributeGroup.new 
     43      @attributes << o 
     44      o 
    4345    when AnyAttributeName 
    44       @anyattribute = AnyAttribute.new 
     46      o = AnyAttribute.new 
     47      @attributes << o 
     48      o 
    4549    end 
    4650  end 
  • trunk/lib/wsdl/xmlSchema/simpleRestriction.rb

    r1911 r1917  
    3030  attr_accessor :fractiondigits 
    3131  attr_reader :fixed 
    32   attr_accessor :anyattribute 
     32  attr_reader :attributes 
    3333 
    3434  def initialize 
     
    4141    @pattern = nil 
    4242    @fixed = {} 
    43     @anyattribute = nil 
     43    @attributes = XSD::NamedElements.new 
    4444  end 
    4545   
     
    8383    when FractionDigitsName 
    8484      FractionDigits.new 
     85    when AttributeName 
     86      o = Attribute.new 
     87      @attributes << o 
     88      o 
     89    when AttributeGroupName 
     90      o = AttributeGroup.new 
     91      @attributes << o 
     92      o 
    8593    when AnyAttributeName 
    86       @anyattribute = AnyAttribute.new 
     94      o = AnyAttribute.new 
     95      @attributes << o 
     96      o 
    8797    end 
    8898  end 
  • trunk/lib/xsd/namedelements.rb

    r1824 r1917  
    9595  end 
    9696 
     97  def find_all 
     98    o = NamedElements.new 
     99    each do |ele| 
     100      o << ele if yield(ele) 
     101    end 
     102    o 
     103  end 
     104 
    97105  Empty = NamedElements.new.freeze 
    98106 
  • trunk/test/wsdl/group/expectedClassdef.rb

    r1906 r1917  
    99#   eletype - SOAP::SOAPString 
    1010#   var - SOAP::SOAPString 
     11#   xmlattr_attr_min - SOAP::SOAPDecimal 
     12#   xmlattr_attr_max - SOAP::SOAPDecimal 
    1113class Groupele_type 
     14  AttrAttr_max = XSD::QName.new(nil, "attr_max") 
     15  AttrAttr_min = XSD::QName.new(nil, "attr_min") 
     16 
    1217  attr_accessor :comment 
    1318  attr_reader :__xmlele_any 
     
    2025  end 
    2126 
     27  def __xmlattr 
     28    @__xmlattr ||= {} 
     29  end 
     30 
     31  def xmlattr_attr_min 
     32    __xmlattr[AttrAttr_min] 
     33  end 
     34 
     35  def xmlattr_attr_min=(value) 
     36    __xmlattr[AttrAttr_min] = value 
     37  end 
     38 
     39  def xmlattr_attr_max 
     40    __xmlattr[AttrAttr_max] 
     41  end 
     42 
     43  def xmlattr_attr_max=(value) 
     44    __xmlattr[AttrAttr_max] = value 
     45  end 
     46 
    2247  def initialize(comment = nil, element = nil, eletype = nil, var = nil) 
    2348    @comment = comment 
     
    2651    @eletype = eletype 
    2752    @var = var 
     53    @__xmlattr = {} 
    2854  end 
    2955end 
  • trunk/test/wsdl/group/expectedMappingRegistry.rb

    r1906 r1917  
    2222      ], 
    2323      ["var", ["SOAP::SOAPString", XSD::QName.new(nil, "var")]] 
    24     ] 
     24    ], 
     25    :schema_attribute => { 
     26      XSD::QName.new(nil, "attr_min") => "SOAP::SOAPDecimal", 
     27      XSD::QName.new(nil, "attr_max") => "SOAP::SOAPDecimal" 
     28    } 
    2529  ) 
    2630 
     
    3842      ], 
    3943      ["var", ["SOAP::SOAPString", XSD::QName.new(nil, "var")]] 
    40     ] 
     44    ], 
     45    :schema_attribute => { 
     46      XSD::QName.new(nil, "attr_min") => "SOAP::SOAPDecimal", 
     47      XSD::QName.new(nil, "attr_max") => "SOAP::SOAPDecimal" 
     48    } 
    4149  ) 
    4250 
     
    5462      ], 
    5563      ["var", ["SOAP::SOAPString", XSD::QName.new(nil, "var")]] 
    56     ] 
     64    ], 
     65    :schema_attribute => { 
     66      XSD::QName.new(nil, "attr_min") => "SOAP::SOAPDecimal", 
     67      XSD::QName.new(nil, "attr_max") => "SOAP::SOAPDecimal" 
     68    } 
    5769  ) 
    5870end 
  • trunk/test/wsdl/group/group.wsdl

    r1906 r1917  
    88    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    99    xmlns="http://schemas.xmlsoap.org/wsdl/"> 
    10   <types> 
    11     <xsd:schema elementFormDefault="unqualified" targetNamespace="urn:grouptype"> 
     10    <types> 
     11      <xsd:schema elementFormDefault="unqualified" targetNamespace="urn:grouptype"> 
    1212 
    13       <xsd:element name="comment" type="xsd:string"/> 
     13        <xsd:element name="comment" type="xsd:string"/> 
    1414 
    15       <xsd:group name="common"> 
    16         <xsd:sequence
    17           <xsd:element ref="txd:comment" minOccurs="0"/> 
    18           <xsd:any namespace="##any" minOccurs="0"/> 
    19         </xsd:sequence
    20       </xsd:group
     15        <xsd:simpleType name="attr_type"> 
     16          <xsd:restriction base="xsd:decimal"
     17            <xsd:maxInclusive value="-50"/> 
     18            <xsd:minInclusive value="50"/> 
     19          </xsd:restriction
     20        </xsd:simpleType
    2121 
    22       <xsd:group name="common_element"> 
    23         <xsd:sequence> 
    24           <xsd:group ref="txd:common"/> 
    25           <xsd:choice> 
    26             <xsd:element name="element" type="xsd:string"/> 
    27             <xsd:element name="eletype" type="xsd:string"/> 
    28           </xsd:choice> 
    29         </xsd:sequence> 
    30       </xsd:group> 
     22        <xsd:group name="common"> 
     23          <xsd:sequence> 
     24            <xsd:element ref="txd:comment" minOccurs="0"/> 
     25            <xsd:any namespace="##any" minOccurs="0"/> 
     26          </xsd:sequence> 
     27        </xsd:group> 
    3128 
    32       <xsd:complexType name="groupele_type"> 
    33         <xsd:sequence> 
    34           <xsd:group ref="txd:common_element"/> 
    35           <xsd:element name="var" type="xsd:string"/> 
    36         </xsd:sequence> 
    37       </xsd:complexType> 
     29        <xsd:attributeGroup name="common_attr"> 
     30          <xsd:attribute name="attr_min" type="txd:attr_type" default="0"/> 
     31          <xsd:attribute name="attr_max" type="txd:attr_type" default="0"/> 
     32        </xsd:attributeGroup> 
    3833 
    39       <xsd:element name="groupele" type="txd:groupele_type"/> 
    40     </xsd:schema> 
    41   </types> 
     34        <xsd:group name="common_element"> 
     35          <xsd:sequence> 
     36            <xsd:group ref="txd:common"/> 
     37            <xsd:choice> 
     38              <xsd:element name="element" type="xsd:string"/> 
     39              <xsd:element name="eletype" type="xsd:string"/> 
     40            </xsd:choice> 
     41          </xsd:sequence> 
     42        </xsd:group> 
     43 
     44        <xsd:complexType name="groupele_type"> 
     45          <xsd:sequence> 
     46            <xsd:group ref="txd:common_element"/> 
     47            <xsd:element name="var" type="xsd:string"/> 
     48          </xsd:sequence> 
     49          <xsd:attributeGroup ref="txd:common_attr"/> 
     50        </xsd:complexType> 
     51 
     52        <xsd:element name="groupele" type="txd:groupele_type"/> 
     53      </xsd:schema> 
     54    </types> 
    4255 
    4356  <message name="echo_in"> 
  • trunk/test/wsdl/group/test_rpc.rb

    r1906 r1917  
    2929      # need to convert for 'any' 
    3030      ret = Groupele_type.new(arg.comment, arg.element, arg.eletype, arg.var) 
     31      ret.xmlattr_attr_max = arg.xmlattr_attr_max 
     32      ret.xmlattr_attr_min = arg.xmlattr_attr_min 
    3133      ret.set_any([::SOAP::SOAPElement.new("foo", arg.foo)]) 
    3234      ret 
     
    128130    arg.eletype = "eletype" 
    129131    arg.var = "var" 
     132    arg.xmlattr_attr_min = -3 
     133    arg.xmlattr_attr_max = 3 
    130134    ret = @client.echo(arg) 
    131135    assert_equal(arg.comment, ret.comment)