File: complexContent.rb

package info (click to toggle)
ruby-soap4r 2.0.5-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,016 kB
  • sloc: ruby: 52,729; xml: 266; sh: 42; javascript: 20; makefile: 11; perl: 10
file content (97 lines) | stat: -rw-r--r-- 1,901 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# WSDL4R - XMLSchema complexContent definition for WSDL.
# Copyright (C) 2000-2007  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;
# either the dual license version in 2003, or any later version.


require 'wsdl/info'
require 'xsd/namedelements'


module WSDL
module XMLSchema


class ComplexContent < Info
  attr_accessor :restriction
  attr_accessor :extension
  attr_accessor :mixed

  def initialize
    super
    @restriction = nil
    @extension = nil
    @mixed = false
  end

  def targetnamespace
    parent.targetnamespace
  end

  def elementformdefault
    parent.elementformdefault
  end

  def content
    @extension || @restriction
  end

  def base
    content ? content.base : nil
  end

  def have_any?
    content ? content.have_any? : nil
  end

  def choice?
    content ? content.choice? : nil
  end

  def elements
    content ? content.elements : XSD::NamedElements::Empty
  end

  def attributes
    content ? content.attributes : XSD::NamedElements::Empty
  end

  def nested_elements
    # restrict and extension does not have particle.
    content ? content.nested_elements : XSD::NamedElements::Empty
  end

  def check_type
    if content
      content.check_type
    else
      raise ArgumentError.new("incomplete complexContent")
    end
  end

  def parse_element(element)
    case element
    when RestrictionName
      raise ArgumentError.new("incomplete complexContent") if content
      @restriction = ComplexRestriction.new
    when ExtensionName
      raise ArgumentError.new("incomplete complexContent") if content
      @extension = ComplexExtension.new
    end
  end

  def parse_attr(attr, value)
    case attr
    when MixedAttrName
      @mixed = to_boolean(value)
    else
      nil
    end
  end
end


end
end