Class: Lutaml::Xsd::Validation::Rules::ElementStructureRule

Inherits:
ValidationRule
  • Object
show all
Defined in:
lib/lutaml/xsd/validation/rules/element_structure_rule.rb

Overview

ElementStructureRule validates element existence and structure

This rule checks:

  • Element is defined in schema

  • Element name matches schema definition

  • Namespace is correct

  • Provides suggestions for similar elements if not found

Based on Jing validator element validation algorithm.

Examples:

Using the rule

rule = ElementStructureRule.new
rule.validate(xml_element, schema_element, collector)

See Also:

  • Element Validation

Constant Summary

Constants inherited from ValidationRule

ValidationRule::CATEGORIES

Instance Attribute Summary

Attributes inherited from ValidationRule

#options

Instance Method Summary collapse

Methods inherited from ValidationRule

#applicable?, #disable!, #enable!, #enabled?, #initialize, #inspect, #option, #priority, #to_h, #to_s

Constructor Details

This class inherits a constructor from Lutaml::Xsd::Validation::ValidationRule

Instance Method Details

#categorySymbol

Rule category

Returns:

  • (Symbol)

    :structure



28
29
30
# File 'lib/lutaml/xsd/validation/rules/element_structure_rule.rb', line 28

def category
  :structure
end

#descriptionString

Rule description

Returns:

  • (String)


35
36
37
# File 'lib/lutaml/xsd/validation/rules/element_structure_rule.rb', line 35

def description
  "Validates element existence, name, and namespace correctness"
end

#validate(xml_element, schema_element, collector) ⇒ void

This method returns an undefined value.

Validate element structure

Performs structural validation of XML elements against schema definitions, including element existence, name matching, and namespace validation.

Parameters:



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/lutaml/xsd/validation/rules/element_structure_rule.rb', line 51

def validate(xml_element, schema_element, collector)
  # Step 1: Validate element declaration exists
  unless validate_element_exists(xml_element, schema_element,
                                 collector)
    return
  end

  # Step 2: Validate element name matches
  validate_element_name(xml_element, schema_element, collector)

  # Step 3: Validate namespace correctness
  validate_namespace(xml_element, schema_element, collector)
end