~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to lib/wsdl/xmlSchema/complexContent.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# WSDL4R - XMLSchema complexContent definition for WSDL.
 
2
# Copyright (C) 2002, 2003  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 'xsd/namedelements'
 
11
 
 
12
 
 
13
module WSDL
 
14
module XMLSchema
 
15
 
 
16
 
 
17
class ComplexContent < Info
 
18
  attr_accessor :base
 
19
  attr_reader :derivetype
 
20
  attr_reader :content
 
21
  attr_reader :attributes
 
22
 
 
23
  def initialize
 
24
    super
 
25
    @base = nil
 
26
    @derivetype = nil
 
27
    @content = nil
 
28
    @attributes = XSD::NamedElements.new
 
29
    @basetype = nil
 
30
  end
 
31
 
 
32
  def targetnamespace
 
33
    parent.targetnamespace
 
34
  end
 
35
 
 
36
  def elementformdefault
 
37
    parent.elementformdefault
 
38
  end
 
39
 
 
40
  def basetype
 
41
    @basetype ||= root.collect_complextypes[@base]
 
42
  end
 
43
 
 
44
  def parse_element(element)
 
45
    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
 
74
    end
 
75
  end
 
76
 
 
77
  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
 
87
  end
 
88
end
 
89
 
 
90
 
 
91
end
 
92
end