| 1 |
# WSDL4R - XMLSchema complexContent definition for WSDL. |
|---|
| 2 |
# Copyright (C) 2000-2007 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 :restriction |
|---|
| 19 |
attr_accessor :extension |
|---|
| 20 |
attr_accessor :mixed |
|---|
| 21 |
|
|---|
| 22 |
def initialize |
|---|
| 23 |
super |
|---|
| 24 |
@restriction = nil |
|---|
| 25 |
@extension = nil |
|---|
| 26 |
@mixed = false |
|---|
| 27 |
end |
|---|
| 28 |
|
|---|
| 29 |
def targetnamespace |
|---|
| 30 |
parent.targetnamespace |
|---|
| 31 |
end |
|---|
| 32 |
|
|---|
| 33 |
def elementformdefault |
|---|
| 34 |
parent.elementformdefault |
|---|
| 35 |
end |
|---|
| 36 |
|
|---|
| 37 |
def content |
|---|
| 38 |
@extension || @restriction |
|---|
| 39 |
end |
|---|
| 40 |
|
|---|
| 41 |
def base |
|---|
| 42 |
content ? content.base : nil |
|---|
| 43 |
end |
|---|
| 44 |
|
|---|
| 45 |
def have_any? |
|---|
| 46 |
content ? content.have_any? : nil |
|---|
| 47 |
end |
|---|
| 48 |
|
|---|
| 49 |
def choice? |
|---|
| 50 |
content ? content.choice? : nil |
|---|
| 51 |
end |
|---|
| 52 |
|
|---|
| 53 |
def elements |
|---|
| 54 |
content ? content.elements : XSD::NamedElements::Empty |
|---|
| 55 |
end |
|---|
| 56 |
|
|---|
| 57 |
def attributes |
|---|
| 58 |
content ? content.attributes : XSD::NamedElements::Empty |
|---|
| 59 |
end |
|---|
| 60 |
|
|---|
| 61 |
def nested_elements |
|---|
| 62 |
# restrict and extension does not have particle. |
|---|
| 63 |
content ? content.nested_elements : XSD::NamedElements::Empty |
|---|
| 64 |
end |
|---|
| 65 |
|
|---|
| 66 |
def check_type |
|---|
| 67 |
if content |
|---|
| 68 |
content.check_type |
|---|
| 69 |
else |
|---|
| 70 |
raise ArgumentError.new("incomplete complexContent") |
|---|
| 71 |
end |
|---|
| 72 |
end |
|---|
| 73 |
|
|---|
| 74 |
def parse_element(element) |
|---|
| 75 |
case element |
|---|
| 76 |
when RestrictionName |
|---|
| 77 |
raise ArgumentError.new("incomplete complexContent") if content |
|---|
| 78 |
@restriction = ComplexRestriction.new |
|---|
| 79 |
when ExtensionName |
|---|
| 80 |
raise ArgumentError.new("incomplete complexContent") if content |
|---|
| 81 |
@extension = ComplexExtension.new |
|---|
| 82 |
end |
|---|
| 83 |
end |
|---|
| 84 |
|
|---|
| 85 |
def parse_attr(attr, value) |
|---|
| 86 |
case attr |
|---|
| 87 |
when MixedAttrName |
|---|
| 88 |
@mixed = to_boolean(value) |
|---|
| 89 |
else |
|---|
| 90 |
nil |
|---|
| 91 |
end |
|---|
| 92 |
end |
|---|
| 93 |
end |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
end |
|---|
| 97 |
end |
|---|