Class: Lutaml::Xml::Schema::Xsd::Element

Inherits:
Base show all
Defined in:
lib/lutaml/xml/schema/xsd/element.rb

Constant Summary

Constants inherited from Base

Base::ELEMENT_ORDER_IGNORABLE, Base::XML_DECLARATION_REGEX

Constants included from Model::Serialize

Model::Serialize::DEFAULT_VALUE_MAP, Model::Serialize::INTERNAL_ATTRIBUTES, Model::Serialize::LAZY_EMPTY_COLLECTION

Instance Attribute Summary

Attributes included from Model::Serialize

#lutaml_parent, #lutaml_register, #lutaml_root

Instance Method Summary collapse

Methods inherited from Base

#all?, #annotation?, #any?, #assign_root!, #attribute?, #attribute_group?, #choice?, #complex_content?, #element?, #max_occurrences, #min_occurrences, #resolved_element_order, #sequence?, #simple_content?, #target_prefix, #to_formatted_xml, #unresolvable_items

Methods included from Model::Serialize

#attr_value, #attribute_exist?, #extract_register_id, included, #init_deserialization_state, #initialize, #key_exist?, #key_value, #method_missing, #prepare_instance_format_options, #pretty_print_instance_variables, register_format_mapping_method, register_from_format_method, register_to_format_method, #respond_to_missing?, #to_format, #to_yaml_hash, #using_default?, #using_default_for, #validate_attribute!, #validate_root_mapping!, #value_map, #value_set_for

Methods included from Model::Liquefiable

included, #to_liquid

Methods included from Model::Validation

#format_element_sequences, #order_names, #validate, #validate!, #validate_helper, #validate_sequence!

Methods included from Model::ComparableModel

#already_compared?, #attributes_hash, #calculate_hash, #comparison_key, #eql?, #hash, included, #same_class?

Methods included from Model::Serialize::Builder

#initialize, #mixed_content?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lutaml::Model::Serialize

Instance Method Details

#attributesObject

Delegate attribute lookup to the complex type referenced by this element, if any.



78
79
80
# File 'lib/lutaml/xml/schema/xsd/element.rb', line 78

def attributes
  referenced_complex_type&.attribute_elements
end

#child_elements(array = []) ⇒ Object

Delegate child-element discovery to the referenced complex type.



83
84
85
# File 'lib/lutaml/xml/schema/xsd/element.rb', line 83

def child_elements(array = [])
  referenced_complex_type&.child_elements(array)
end

#referenced_complex_typeObject

Resolve the complex type referenced by the effective element type.



106
107
108
109
110
# File 'lib/lutaml/xml/schema/xsd/element.rb', line 106

def referenced_complex_type
  return complex_type if complex_type

  find_object(xsd_root.complex_type, referenced_type)
end

#referenced_nameObject

Return the effective element name after resolving ‘ref`.



88
89
90
# File 'lib/lutaml/xml/schema/xsd/element.rb', line 88

def referenced_name
  referenced_object&.name || ref
end

#referenced_objectObject

Return the element itself when it is named, otherwise resolve the root-level element referenced by ‘ref`.



99
100
101
102
103
# File 'lib/lutaml/xml/schema/xsd/element.rb', line 99

def referenced_object
  return self if name

  find_object(xsd_root.element)
end

#referenced_typeObject

Return the effective element type after resolving ‘ref`.



93
94
95
# File 'lib/lutaml/xml/schema/xsd/element.rb', line 93

def referenced_type
  referenced_object&.type
end

#used_byObject

Return complex types whose nested content model references this element by name.



70
71
72
73
74
# File 'lib/lutaml/xml/schema/xsd/element.rb', line 70

def used_by
  xsd_root.complex_type.select do |object|
    object.find_elements_used(name)
  end
end