Class: Lutaml::Xsd::Validation::Rules::ContentModelValidationRule
- Inherits:
-
ValidationRule
- Object
- ValidationRule
- Lutaml::Xsd::Validation::Rules::ContentModelValidationRule
- Defined in:
- lib/lutaml/xsd/validation/rules/content_model_validation_rule.rb
Overview
ContentModelValidationRule validates content models
This rule checks:
-
xs:sequence (order matters)
-
xs:choice (one of alternatives)
-
xs:all (all must appear, order doesn’t matter)
-
Nested sequences/choices
Based on Jing validator content model validation algorithm.
Constant Summary
Constants inherited from ValidationRule
Instance Attribute Summary
Attributes inherited from ValidationRule
Instance Method Summary collapse
-
#category ⇒ Symbol
Rule category.
-
#description ⇒ String
Rule description.
-
#validate(xml_element, schema_def, collector) ⇒ void
Validate content model.
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
#category ⇒ Symbol
Rule category
28 29 30 |
# File 'lib/lutaml/xsd/validation/rules/content_model_validation_rule.rb', line 28 def category :structure end |
#description ⇒ String
Rule description
35 36 37 |
# File 'lib/lutaml/xsd/validation/rules/content_model_validation_rule.rb', line 35 def description "Validates element content models (sequence, choice, all)" end |
#validate(xml_element, schema_def, collector) ⇒ void
This method returns an undefined value.
Validate content model
Validates element children against the schema’s content model, ensuring correct order (sequence), alternatives (choice), or completeness (all).
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/lutaml/xsd/validation/rules/content_model_validation_rule.rb', line 50 def validate(xml_element, schema_def, collector) return unless schema_def # Resolve content model content_model = resolve_content_model(schema_def) return unless content_model # Validate based on content model type case content_model when Lutaml::Xsd::Sequence validate_sequence(xml_element, content_model, collector) when Lutaml::Xsd::Choice validate_choice(xml_element, content_model, collector) when Lutaml::Xsd::All validate_all(xml_element, content_model, collector) end end |