Class: XSD::ComplexType
- Inherits:
-
BaseObject
- Object
- BaseObject
- XSD::ComplexType
- Includes:
- AttributeContainer, Named
- Defined in:
- lib/xsd/objects/complex_type.rb
Overview
The complexType element defines a complex type. A complex type element is an XML element that contains other elements and/or attributes. Parent elements: element, redefine, schema www.w3schools.com/xml/el_complextype.asp
Constant Summary
Constants inherited from BaseObject
BaseObject::NO_ATTRIBUTES_CONTAINER, BaseObject::NO_ELEMENTS_CONTAINER, BaseObject::XML_SCHEMA
Instance Attribute Summary collapse
-
#abstract ⇒ Object
Optional.
-
#all ⇒ Object
Nested all.
-
#block ⇒ Object
Optional.
-
#choice ⇒ Object
Nested choice.
-
#complex_content ⇒ Object
Complex content object.
-
#final ⇒ Object
Optional.
-
#group ⇒ Object
Nested group.
-
#mixed ⇒ Object
Optional.
-
#name ⇒ Object
Optional.
-
#sequence ⇒ Object
Nested sequence.
-
#simple_content ⇒ Object
Simple content object.
Attributes included from AttributeContainer
#attribute_groups, #attributes
Attributes inherited from BaseObject
Instance Method Summary collapse
-
#complex_content? ⇒ Boolean
Determine if this type has complex content definition.
-
#data_type ⇒ Object
Get simple content data type.
-
#linked? ⇒ Boolean
Determine if this is a linked type.
-
#mixed_content? ⇒ Boolean
Determine if this type has mixed content definition.
-
#simple_content? ⇒ Boolean
Determine if this type has simple content definition.
Methods included from Named
Methods included from AttributeContainer
Methods inherited from BaseObject
#[], #collect_attributes, #collect_elements, #documentation, #documentation_for, #get_prefix, #initialize, #inspect, #map_child, #map_children, #namespaces, #node, #node_to_object, #nodes, #object_by_name, #parent, #reader, #schema, #schemas_for_namespace, #strip_prefix
Constructor Details
This class inherits a constructor from XSD::BaseObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class XSD::BaseObject
Instance Attribute Details
#abstract ⇒ Object
Optional. Specifies whether the complex type can be used in an instance document. True indicates that an element cannot use this complex type directly but must use a complex type derived from this complex type. Default is false
21 |
# File 'lib/xsd/objects/complex_type.rb', line 21 property :abstract, :boolean, default: false |
#all ⇒ Object
Nested all
65 |
# File 'lib/xsd/objects/complex_type.rb', line 65 child :all, :all |
#block ⇒ Object
Optional. Prevents a complex type that has a specified type of derivation from being used in place of this complex type. This value can contain #all or a list that is a subset of extension or restriction:
extension - prevents complex types derived by extension
restriction - prevents complex types derived by restriction
#all - prevents all derived complex types
36 |
# File 'lib/xsd/objects/complex_type.rb', line 36 property :block, :string |
#choice ⇒ Object
Nested choice
70 |
# File 'lib/xsd/objects/complex_type.rb', line 70 child :choice, :choice |
#complex_content ⇒ Object
Complex content object
55 |
# File 'lib/xsd/objects/complex_type.rb', line 55 child :complex_content, :complexContent |
#final ⇒ Object
Optional. Prevents a specified type of derivation of this complex type element. Can contain #all or a list that is a subset of extension or restriction.
extension - prevents derivation by extension
restriction - prevents derivation by restriction
#all - prevents all derivation
45 |
# File 'lib/xsd/objects/complex_type.rb', line 45 property :final, :string |
#group ⇒ Object
Nested group
60 |
# File 'lib/xsd/objects/complex_type.rb', line 60 child :group, :group |
#mixed ⇒ Object
Optional. Specifies whether character data is allowed to appear between the child elements of this complexType element. Default is false. If a simpleContent element is a child element, the mixed attribute is not allowed!
27 |
# File 'lib/xsd/objects/complex_type.rb', line 27 property :mixed, :boolean, default: false |
#name ⇒ Object
Optional. Specifies a name for the element
15 |
# File 'lib/xsd/objects/complex_type.rb', line 15 property :name, :string |
#sequence ⇒ Object
Nested sequence
75 |
# File 'lib/xsd/objects/complex_type.rb', line 75 child :sequence, :sequence |
#simple_content ⇒ Object
Simple content object
50 |
# File 'lib/xsd/objects/complex_type.rb', line 50 child :simple_content, :simpleContent |
Instance Method Details
#complex_content? ⇒ Boolean
Determine if this type has complex content definition
99 100 101 102 103 104 105 106 107 |
# File 'lib/xsd/objects/complex_type.rb', line 99 def complex_content? if simple_content false elsif complex_content true else group || all || choice || sequence end end |
#data_type ⇒ Object
Get simple content data type
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/xsd/objects/complex_type.rb', line 117 def data_type return nil unless simple_content restriction = simple_content.restriction if restriction if restriction.base if restriction.base_simple_type restriction.base_simple_type.data_type elsif restriction.base_complex_type restriction.base_complex_type.data_type else strip_prefix(restriction.base) end else restriction.simple_type&.data_type end else extension = simple_content.extension extension.base_simple_type&.data_type || strip_prefix(extension.base) end end |
#linked? ⇒ Boolean
Determine if this is a linked type
79 80 81 |
# File 'lib/xsd/objects/complex_type.rb', line 79 def linked? !name.nil? end |
#mixed_content? ⇒ Boolean
Determine if this type has mixed content definition
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/xsd/objects/complex_type.rb', line 85 def mixed_content? return true if mixed if complex_content return true if complex_content.mixed return (complex_content.extension || complex_content.restriction).base_complex_type&.mixed_content? end false end |
#simple_content? ⇒ Boolean
Determine if this type has simple content definition
111 112 113 |
# File 'lib/xsd/objects/complex_type.rb', line 111 def simple_content? !!simple_content end |