Class: SvgConform::Requirements::LinkValidationRequirement
- Inherits:
-
BaseRequirement
- Object
- Lutaml::Model::Serializable
- BaseRequirement
- SvgConform::Requirements::LinkValidationRequirement
- Defined in:
- lib/svg_conform/requirements/link_validation_requirement.rb
Instance Method Summary collapse
Methods inherited from BaseRequirement
#collect_sax_data, #element?, #get_attribute, #get_attributes, #has_attribute?, #needs_deferred_validation?, #remove_attribute, #set_attribute, #should_check_node?, #text?, #to_s, #validate_document, #validate_sax_complete
Instance Method Details
#check(node, context) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/svg_conform/requirements/link_validation_requirement.rb', line 9 def check(node, context) return unless element?(node) # Check href attributes (both href and xlink:href) href_value = extract_href(node) return unless href_value # Always validate ASCII requirement (applies to all references) validate_ascii(href_value, node, context) # Classify and register the reference reference = classify_reference(href_value, node) return unless reference context.register_reference(reference) # Only validate internal references if reference.internally_validatable? validate_internal_reference(reference, node, context) elsif reference.requires_consumer_validation? # Don't error - just notify consumer context.add_external_reference_notice( node: node, reference: reference, ) end # Check other IRI attributes iri_attributes = %w[src action formaction cite longdesc usemap] iri_attributes.each do |attr_name| iri_value = get_attribute(node, attr_name) next unless iri_value validate_ascii_attribute(iri_value, attr_name, node, context) # Classify and register these references too iri_ref = classify_reference(iri_value, node, attr_name) context.register_reference(iri_ref) if iri_ref end end |
#validate_sax_element(element, context) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/svg_conform/requirements/link_validation_requirement.rb', line 50 def validate_sax_element(element, context) # Check href attributes href_value = element.raw_attributes["href"] || element.raw_attributes["xlink:href"] if href_value validate_ascii(href_value, element, context) # Classify and register reference = References::ReferenceClassifier.classify( href_value, element_name: element.name, attribute_name: "href", line_number: element.line, column_number: element.column, ) if reference context.register_reference(reference) if reference.internally_validatable? validate_internal_reference(reference, element, context) elsif reference.requires_consumer_validation? context.add_external_reference_notice( node: element, reference: reference, ) end end end # Check other IRI attributes iri_attributes = %w[src action formaction cite longdesc usemap] iri_attributes.each do |attr_name| iri_value = element.raw_attributes[attr_name] next unless iri_value validate_ascii_attribute(iri_value, attr_name, element, context) # Classify and register iri_ref = References::ReferenceClassifier.classify( iri_value, element_name: element.name, attribute_name: attr_name, line_number: element.line, column_number: element.column, ) context.register_reference(iri_ref) if iri_ref end end |