Class: XSD::ComplexType

Inherits:
BaseObject show all
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 https://www.w3schools.com/xml/el_complextype.asp

Constant Summary

Constants inherited from BaseObject

BaseObject::NO_ATTRIBUTES_CONTAINER, BaseObject::NO_ELEMENTS_CONTAINER, BaseObject::XML_SCHEMA, BaseObject::XML_SCHEMA_NS

Instance Attribute Summary collapse

Attributes included from AttributeContainer

#attribute_groups, #attributes

Attributes inherited from BaseObject

#id, #options

Instance Method Summary collapse

Methods included from Named

#absolute_name, #namespace

Methods included from AttributeContainer

included

Methods inherited from BaseObject

#[], child, #collect_attributes, #collect_elements, #documentation, #documentation_for, #get_prefix, #initialize, #inspect, link, #map_child, #map_children, mapped_name, #namespaces, #node, #node_to_object, #nodes, #object_by_name, #parent, property, #reader, #schema, #schemas_for_namespace, #strip_prefix, to_underscore

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

Returns:

  • Boolean



21
# File 'lib/xsd/objects/complex_type.rb', line 21

property :abstract, :boolean, default: false

#all ⇒ Object

Nested all

Returns:

  • 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

Returns:

  • String, nil



36
# File 'lib/xsd/objects/complex_type.rb', line 36

property :block, :string

#choice ⇒ Object

Nested choice

Returns:

  • Choice



70
# File 'lib/xsd/objects/complex_type.rb', line 70

child :choice, :choice

#complex_content ⇒ Object

Complex content object

Returns:

  • ComplexContent



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

Returns:

  • String, nil



45
# File 'lib/xsd/objects/complex_type.rb', line 45

property :final, :string

#group ⇒ Object

Nested group

Returns:

  • 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!

Returns:

  • Boolean



27
# File 'lib/xsd/objects/complex_type.rb', line 27

property :mixed, :boolean, default: false

#name ⇒ Object

Optional. Specifies a name for the element

Returns:

  • String



15
# File 'lib/xsd/objects/complex_type.rb', line 15

property :name, :string

#sequence ⇒ Object

Nested sequence

Returns:

  • Sequence



75
# File 'lib/xsd/objects/complex_type.rb', line 75

child :sequence, :sequence

#simple_content ⇒ Object

Simple content object

Returns:

  • SimpleContent



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

Returns:

  • (Boolean) —

    Boolean



101
102
103
104
105
106
107
108
109
# File 'lib/xsd/objects/complex_type.rb', line 101

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

Returns:

  • String, nil



119
120
121
122
123
124
125
126
127
# File 'lib/xsd/objects/complex_type.rb', line 119

def data_type
  return nil unless simple_content

  restriction = simple_content.restriction
  return base_data_type(simple_content.extension) unless restriction
  return restriction.simple_type&.data_type unless restriction.base

  base_data_type(restriction)
end

#linked? ⇒ Boolean

Determine if this is a linked type

Returns:

  • (Boolean) —

    Boolean



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

Returns:

  • (Boolean) —

    Boolean



85
86
87
88
89
90
91
92
93
94
95
96
97
# 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

    derivation = complex_content.extension || complex_content.restriction

    return derivation&.base_complex_type&.mixed_content? || false
  end

  false
end

#simple_content? ⇒ Boolean

Determine if this type has simple content definition

Returns:

  • (Boolean) —

    Boolean



113
114
115
# File 'lib/xsd/objects/complex_type.rb', line 113

def simple_content?
  !!simple_content
end