lutaml 0.11.7 → 0.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +0 -1
- data/Gemfile +32 -5
- data/README.adoc +3 -3
- data/README.md +6 -8
- data/Rakefile +41 -1
- data/bin/console +0 -1
- data/exe/lutaml-lml +6 -0
- data/exe/lutaml-lml-lsp +11 -0
- data/lib/compat/opal/generate_boot.rb +132 -0
- data/lib/compat/opal/js_bundle_entry.rb +42 -0
- data/lib/compat/opal/lutaml_model_boot.rb +540 -0
- data/lib/compat/opal/monitor.rb +31 -0
- data/lib/compat/opal/moxml/adapter/customized_rexml/entity_reference.rb +9 -0
- data/lib/compat/opal/moxml/adapter/customized_rexml/formatter.rb +225 -0
- data/lib/compat/opal/moxml/adapter/customized_rexml.rb +11 -0
- data/lib/compat/opal/moxml_boot.rb +68 -0
- data/lib/compat/opal/objectspace_shim.rb +23 -0
- data/lib/compat/opal/rexml/namespace.rb +59 -0
- data/lib/compat/opal/rexml/parsers/baseparser.rb +1016 -0
- data/lib/compat/opal/rexml/source.rb +214 -0
- data/lib/compat/opal/rexml/text.rb +426 -0
- data/lib/compat/opal/rexml/xmltokens.rb +45 -0
- data/lib/compat/opal/rexml_compat.rb +85 -0
- data/lib/compat/opal/yaml_compat.rb +32 -0
- data/lib/lutaml/hash_format/adapter/document.rb +10 -0
- data/lib/lutaml/hash_format/adapter/mapping.rb +17 -0
- data/lib/lutaml/hash_format/adapter/mapping_rule.rb +9 -0
- data/lib/lutaml/hash_format/adapter/standard_adapter.rb +17 -0
- data/lib/lutaml/hash_format/adapter/transform.rb +9 -0
- data/lib/lutaml/hash_format/adapter.rb +13 -0
- data/lib/lutaml/hash_format/format.rb +29 -0
- data/lib/lutaml/hash_format/type/serializers.rb +24 -0
- data/lib/lutaml/hash_format.rb +7 -0
- data/lib/lutaml/json/adapter/document.rb +13 -0
- data/lib/lutaml/json/adapter/mapping.rb +17 -0
- data/lib/lutaml/json/adapter/mapping_rule.rb +9 -0
- data/lib/lutaml/json/adapter/multi_json_adapter.rb +45 -0
- data/lib/lutaml/json/adapter/oj_adapter.rb +41 -0
- data/lib/lutaml/json/adapter/standard_adapter.rb +43 -0
- data/lib/lutaml/json/adapter/transform.rb +9 -0
- data/lib/lutaml/json/adapter/yeptris_adapter.rb +74 -0
- data/lib/lutaml/json/adapter.rb +21 -0
- data/lib/lutaml/json/format.rb +61 -0
- data/lib/lutaml/json/generator_options.rb +62 -0
- data/lib/lutaml/json/schema/json_schema.rb +62 -0
- data/lib/lutaml/json/schema.rb +9 -0
- data/lib/lutaml/json/type/serializers.rb +72 -0
- data/lib/lutaml/json.rb +7 -0
- data/lib/lutaml/jsonl/adapter/document.rb +14 -0
- data/lib/lutaml/jsonl/adapter/mapping.rb +17 -0
- data/lib/lutaml/jsonl/adapter/mapping_rule.rb +9 -0
- data/lib/lutaml/jsonl/adapter/standard_adapter.rb +34 -0
- data/lib/lutaml/jsonl/adapter/transform.rb +26 -0
- data/lib/lutaml/jsonl/adapter.rb +13 -0
- data/lib/lutaml/jsonl/format.rb +22 -0
- data/lib/lutaml/jsonl.rb +7 -0
- data/lib/lutaml/jsonld/adapter.rb +31 -0
- data/lib/lutaml/jsonld.rb +20 -0
- data/lib/lutaml/key_value/adapter/hash/document.rb +13 -0
- data/lib/lutaml/key_value/adapter/hash/mapping.rb +17 -0
- data/lib/lutaml/key_value/adapter/hash/mapping_rule.rb +9 -0
- data/lib/lutaml/key_value/adapter/hash/standard_adapter.rb +19 -0
- data/lib/lutaml/key_value/adapter/hash/transform.rb +10 -0
- data/lib/lutaml/key_value/adapter/hash.rb +15 -0
- data/lib/lutaml/key_value/adapter/json/document.rb +16 -0
- data/lib/lutaml/key_value/adapter/json/mapping.rb +22 -0
- data/lib/lutaml/key_value/adapter/json/mapping_rule.rb +14 -0
- data/lib/lutaml/key_value/adapter/json/multi_json_adapter.rb +54 -0
- data/lib/lutaml/key_value/adapter/json/oj_adapter.rb +46 -0
- data/lib/lutaml/key_value/adapter/json/standard_adapter.rb +47 -0
- data/lib/lutaml/key_value/adapter/json/transform.rb +14 -0
- data/lib/lutaml/key_value/adapter/json/yeptris_adapter.rb +15 -0
- data/lib/lutaml/key_value/adapter/json.rb +24 -0
- data/lib/lutaml/key_value/adapter/jsonl/document.rb +16 -0
- data/lib/lutaml/key_value/adapter/jsonl/mapping.rb +17 -0
- data/lib/lutaml/key_value/adapter/jsonl/mapping_rule.rb +9 -0
- data/lib/lutaml/key_value/adapter/jsonl/standard_adapter.rb +36 -0
- data/lib/lutaml/key_value/adapter/jsonl/transform.rb +26 -0
- data/lib/lutaml/key_value/adapter/jsonl.rb +17 -0
- data/lib/lutaml/key_value/adapter/toml/document.rb +13 -0
- data/lib/lutaml/key_value/adapter/toml/mapping.rb +26 -0
- data/lib/lutaml/key_value/adapter/toml/mapping_rule.rb +9 -0
- data/lib/lutaml/key_value/adapter/toml/teptris_adapter.rb +36 -0
- data/lib/lutaml/key_value/adapter/toml/toml_rb_adapter.rb +34 -0
- data/lib/lutaml/key_value/adapter/toml/tomlib_adapter.rb +40 -0
- data/lib/lutaml/key_value/adapter/toml/transform.rb +10 -0
- data/lib/lutaml/key_value/adapter/toml.rb +22 -0
- data/lib/lutaml/key_value/adapter/yaml/document.rb +12 -0
- data/lib/lutaml/key_value/adapter/yaml/mapping.rb +17 -0
- data/lib/lutaml/key_value/adapter/yaml/mapping_rule.rb +9 -0
- data/lib/lutaml/key_value/adapter/yaml/standard_adapter.rb +35 -0
- data/lib/lutaml/key_value/adapter/yaml/transform.rb +10 -0
- data/lib/lutaml/key_value/adapter/yaml/yeptris_adapter.rb +15 -0
- data/lib/lutaml/key_value/adapter/yaml.rb +17 -0
- data/lib/lutaml/key_value/adapter/yamls/document.rb +16 -0
- data/lib/lutaml/key_value/adapter/yamls/mapping.rb +17 -0
- data/lib/lutaml/key_value/adapter/yamls/mapping_rule.rb +9 -0
- data/lib/lutaml/key_value/adapter/yamls/standard_adapter.rb +37 -0
- data/lib/lutaml/key_value/adapter/yamls/transform.rb +26 -0
- data/lib/lutaml/key_value/adapter/yamls.rb +17 -0
- data/lib/lutaml/key_value/adapter.rb +14 -0
- data/lib/lutaml/key_value/data_model/element.rb +225 -0
- data/lib/lutaml/key_value/data_model.rb +14 -0
- data/lib/lutaml/key_value/document.rb +28 -0
- data/lib/lutaml/key_value/format.rb +26 -0
- data/lib/lutaml/key_value/mapping.rb +393 -0
- data/lib/lutaml/key_value/mapping_rule.rb +95 -0
- data/lib/lutaml/key_value/transform.rb +1223 -0
- data/lib/lutaml/key_value/transformation/collection_serializer.rb +572 -0
- data/lib/lutaml/key_value/transformation/rule_compiler.rb +299 -0
- data/lib/lutaml/key_value/transformation/value_serializer.rb +399 -0
- data/lib/lutaml/key_value/transformation.rb +1276 -0
- data/lib/lutaml/key_value/transformation_builder.rb +30 -0
- data/lib/lutaml/key_value.rb +7 -0
- data/lib/lutaml/lml/association_label_resolver.rb +52 -0
- data/lib/lutaml/lml/cli.rb +506 -0
- data/lib/lutaml/lml/data_processor/attribute_processing.rb +133 -0
- data/lib/lutaml/lml/data_processor/collection_processing.rb +37 -0
- data/lib/lutaml/lml/data_processor/instance_processing.rb +77 -0
- data/lib/lutaml/lml/data_processor/value_declaration_processing.rb +70 -0
- data/lib/lutaml/lml/data_processor/value_processing.rb +103 -0
- data/lib/lutaml/lml/data_processor/view_processing.rb +26 -0
- data/lib/lutaml/lml/data_processor.rb +59 -0
- data/lib/lutaml/lml/diagnostic.rb +149 -0
- data/lib/lutaml/lml/document_builder.rb +481 -0
- data/lib/lutaml/lml/entity_types.rb +30 -0
- data/lib/lutaml/lml/executor/adapter_helpers.rb +45 -0
- data/lib/lutaml/lml/executor/condition_evaluator.rb +169 -0
- data/lib/lutaml/lml/executor/csv_adapter.rb +88 -0
- data/lib/lutaml/lml/executor/format_adapter.rb +54 -0
- data/lib/lutaml/lml/executor/xml_adapter.rb +102 -0
- data/lib/lutaml/lml/executor.rb +96 -0
- data/lib/lutaml/lml/format/adapter/document.rb +11 -0
- data/lib/lutaml/lml/format/adapter/mapping.rb +31 -0
- data/lib/lutaml/lml/format/adapter/standard_adapter.rb +162 -0
- data/lib/lutaml/lml/format/adapter/transform.rb +11 -0
- data/lib/lutaml/lml/format.rb +29 -0
- data/lib/lutaml/lml/formatter/base.rb +79 -0
- data/lib/lutaml/lml/formatter/canonical.rb +736 -0
- data/lib/lutaml/lml/formatter/elk.rb +45 -0
- data/lib/lutaml/lml/formatter/svg_pdf/path_parser.rb +134 -0
- data/lib/lutaml/lml/formatter/svg_pdf.rb +285 -0
- data/lib/lutaml/lml/formatter.rb +11 -0
- data/lib/lutaml/lml/grammar/lml.artifact.json +14993 -0
- data/lib/lutaml/lml/grammar/lml.parg +389 -0
- data/lib/lutaml/lml/grammar.rb +60 -0
- data/lib/lutaml/lml/has_attributes.rb +14 -0
- data/lib/lutaml/lml/import_resolver.rb +96 -0
- data/lib/lutaml/lml/layout/elk_engine.rb +15 -0
- data/lib/lutaml/lml/layout/elk_graph_builder.rb +129 -0
- data/lib/lutaml/lml/layout/elk_svg_markers.rb +45 -0
- data/lib/lutaml/lml/layout/elk_svg_renderer.rb +119 -0
- data/lib/lutaml/lml/layout/engine.rb +17 -0
- data/lib/lutaml/lml/layout.rb +12 -0
- data/lib/lutaml/lml/literal_value.rb +32 -0
- data/lib/lutaml/lml/lsp/conversions.rb +78 -0
- data/lib/lutaml/lml/lsp/keywords.rb +43 -0
- data/lib/lutaml/lml/lsp/server.rb +378 -0
- data/lib/lutaml/lml/lsp/store.rb +68 -0
- data/lib/lutaml/lml/lsp/transport.rb +53 -0
- data/lib/lutaml/lml/lsp.rb +16 -0
- data/lib/lutaml/lml/model_compiler/enums.rb +172 -0
- data/lib/lutaml/lml/model_compiler/hydration.rb +123 -0
- data/lib/lutaml/lml/model_compiler/serialization_mappings.rb +188 -0
- data/lib/lutaml/lml/model_compiler/string_formats.rb +42 -0
- data/lib/lutaml/lml/model_compiler/validation.rb +65 -0
- data/lib/lutaml/lml/model_compiler.rb +323 -0
- data/lib/lutaml/lml/models/action.rb +10 -0
- data/lib/lutaml/lml/models/association.rb +29 -0
- data/lib/lutaml/lml/models/cardinality.rb +10 -0
- data/lib/lutaml/lml/models/collection.rb +11 -0
- data/lib/lutaml/lml/models/constraint.rb +23 -0
- data/lib/lutaml/lml/models/data_type.rb +41 -0
- data/lib/lutaml/lml/models/derived_field.rb +14 -0
- data/lib/lutaml/lml/models/diagram.rb +20 -0
- data/lib/lutaml/lml/models/document.rb +84 -0
- data/lib/lutaml/lml/models/enum.rb +38 -0
- data/lib/lutaml/lml/models/fidelity.rb +10 -0
- data/lib/lutaml/lml/models/group.rb +11 -0
- data/lib/lutaml/lml/models/instance.rb +26 -0
- data/lib/lutaml/lml/models/instance_collection.rb +16 -0
- data/lib/lutaml/lml/models/instances_export.rb +10 -0
- data/lib/lutaml/lml/models/instances_import.rb +11 -0
- data/lib/lutaml/lml/models/mapping.rb +15 -0
- data/lib/lutaml/lml/models/mapping_rule.rb +16 -0
- data/lib/lutaml/lml/models/member_field.rb +14 -0
- data/lib/lutaml/lml/models/namespace.rb +16 -0
- data/lib/lutaml/lml/models/operation.rb +26 -0
- data/lib/lutaml/lml/models/operation_parameter.rb +12 -0
- data/lib/lutaml/lml/models/package.rb +26 -0
- data/lib/lutaml/lml/models/primitive_type.rb +33 -0
- data/lib/lutaml/lml/models/reference.rb +23 -0
- data/lib/lutaml/lml/models/serialization_mapping.rb +19 -0
- data/lib/lutaml/lml/models/string_format.rb +16 -0
- data/lib/lutaml/lml/models/top_element_attribute.rb +116 -0
- data/lib/lutaml/lml/models/uml_class.rb +85 -0
- data/lib/lutaml/lml/models/value.rb +15 -0
- data/lib/lutaml/lml/models/view_filter.rb +11 -0
- data/lib/lutaml/lml/models/view_import.rb +11 -0
- data/lib/lutaml/lml/parser.rb +19 -0
- data/lib/lutaml/lml/pipeline.rb +73 -0
- data/lib/lutaml/lml/positioned.rb +13 -0
- data/lib/lutaml/lml/preprocessor.rb +130 -0
- data/lib/lutaml/lml/quoting.rb +60 -0
- data/lib/lutaml/lml/source.rb +49 -0
- data/lib/lutaml/lml/source_position.rb +20 -0
- data/lib/lutaml/lml/symbol_index.rb +200 -0
- data/lib/lutaml/lml/transform.rb +119 -0
- data/lib/lutaml/lml/types/text_type.rb +28 -0
- data/lib/lutaml/lml/types.rb +10 -0
- data/lib/lutaml/lml/validator.rb +458 -0
- data/lib/lutaml/lml/version.rb +10 -0
- data/lib/lutaml/lml/view_resolution.rb +32 -0
- data/lib/lutaml/lml/view_resolver.rb +48 -0
- data/lib/lutaml/lml/yaml_parser.rb +17 -0
- data/lib/lutaml/lml.rb +130 -0
- data/lib/lutaml/model/adapter_resolver.rb +487 -0
- data/lib/lutaml/model/adapter_scope.rb +64 -0
- data/lib/lutaml/model/attribute.rb +1511 -0
- data/lib/lutaml/model/attribute_validator.rb +290 -0
- data/lib/lutaml/model/cached_type_resolver/concurrent_map_cache.rb +48 -0
- data/lib/lutaml/model/cached_type_resolver/mutex_hash_cache.rb +53 -0
- data/lib/lutaml/model/cached_type_resolver.rb +145 -0
- data/lib/lutaml/model/choice.rb +343 -0
- data/lib/lutaml/model/cli.rb +85 -0
- data/lib/lutaml/model/collection.rb +740 -0
- data/lib/lutaml/model/collection_handler.rb +157 -0
- data/lib/lutaml/model/comparable_model.rb +710 -0
- data/lib/lutaml/model/comparable_nil.rb +9 -0
- data/lib/lutaml/model/comparison.rb +15 -0
- data/lib/lutaml/model/compiled_rule.rb +242 -0
- data/lib/lutaml/model/config.rb +169 -0
- data/lib/lutaml/model/configuration.rb +138 -0
- data/lib/lutaml/model/consolidation/attribute_grouper.rb +44 -0
- data/lib/lutaml/model/consolidation/dispatcher.rb +45 -0
- data/lib/lutaml/model/consolidation/engine.rb +33 -0
- data/lib/lutaml/model/consolidation/pattern_chunker.rb +87 -0
- data/lib/lutaml/model/consolidation_map.rb +68 -0
- data/lib/lutaml/model/consolidation_rule/dispatch_block.rb +34 -0
- data/lib/lutaml/model/consolidation_rule/gather_rule.rb +17 -0
- data/lib/lutaml/model/consolidation_rule/pattern_content_rule.rb +15 -0
- data/lib/lutaml/model/consolidation_rule/pattern_element_rule.rb +17 -0
- data/lib/lutaml/model/consolidation_rule.rb +27 -0
- data/lib/lutaml/model/constants.rb +11 -0
- data/lib/lutaml/model/context_registry.rb +208 -0
- data/lib/lutaml/model/deep_dupable.rb +16 -0
- data/lib/lutaml/model/error/choice_lower_bound_error.rb +9 -0
- data/lib/lutaml/model/error/choice_upper_bound_error.rb +9 -0
- data/lib/lutaml/model/error/collection_count_out_of_range_error.rb +29 -0
- data/lib/lutaml/model/error/collection_true_missing_error.rb +16 -0
- data/lib/lutaml/model/error/element_count_out_of_range_error.rb +35 -0
- data/lib/lutaml/model/error/format_adapter_not_specified_error.rb +25 -0
- data/lib/lutaml/model/error/fraction_digits_error.rb +20 -0
- data/lib/lutaml/model/error/import_model_with_root_error.rb +9 -0
- data/lib/lutaml/model/error/incorrect_mapping_argument_error.rb +6 -0
- data/lib/lutaml/model/error/incorrect_sequence_error.rb +9 -0
- data/lib/lutaml/model/error/invalid_attribute_name_error.rb +15 -0
- data/lib/lutaml/model/error/invalid_attribute_options_error.rb +16 -0
- data/lib/lutaml/model/error/invalid_attribute_type_error.rb +98 -0
- data/lib/lutaml/model/error/invalid_choice_range_error.rb +18 -0
- data/lib/lutaml/model/error/invalid_format_error.rb +11 -0
- data/lib/lutaml/model/error/invalid_value_error.rb +18 -0
- data/lib/lutaml/model/error/length_error.rb +19 -0
- data/lib/lutaml/model/error/liquid_class_not_found_error.rb +9 -0
- data/lib/lutaml/model/error/liquid_drop_already_registered_error.rb +11 -0
- data/lib/lutaml/model/error/liquid_not_enabled_error.rb +9 -0
- data/lib/lutaml/model/error/mapping_already_exists_error.rb +6 -0
- data/lib/lutaml/model/error/mapping_attribute_missing_error.rb +6 -0
- data/lib/lutaml/model/error/mapping_attribute_type_error.rb +6 -0
- data/lib/lutaml/model/error/max_exclusive_error.rb +19 -0
- data/lib/lutaml/model/error/max_inclusive_error.rb +20 -0
- data/lib/lutaml/model/error/max_length_error.rb +20 -0
- data/lib/lutaml/model/error/min_exclusive_error.rb +19 -0
- data/lib/lutaml/model/error/min_inclusive_error.rb +20 -0
- data/lib/lutaml/model/error/min_length_error.rb +20 -0
- data/lib/lutaml/model/error/mixed_content_collection_error.rb +17 -0
- data/lib/lutaml/model/error/multiple_mappings_error.rb +6 -0
- data/lib/lutaml/model/error/no_attributes_defined_liquid_error.rb +9 -0
- data/lib/lutaml/model/error/no_mapping_found_error.rb +9 -0
- data/lib/lutaml/model/error/no_root_mapping_error.rb +10 -0
- data/lib/lutaml/model/error/no_root_namespace_error.rb +10 -0
- data/lib/lutaml/model/error/ordered_content_mapping_error.rb +17 -0
- data/lib/lutaml/model/error/pattern_not_matched_error.rb +17 -0
- data/lib/lutaml/model/error/polymorphic_error.rb +14 -0
- data/lib/lutaml/model/error/register/not_registrable_class_error.rb +11 -0
- data/lib/lutaml/model/error/required_attribute_missing_error.rb +9 -0
- data/lib/lutaml/model/error/restriction_error.rb +8 -0
- data/lib/lutaml/model/error/reverse_transform_block_not_defined_error.rb +6 -0
- data/lib/lutaml/model/error/reverse_transformation_declaration_error.rb +6 -0
- data/lib/lutaml/model/error/sorting_configuration_conflict_error.rb +9 -0
- data/lib/lutaml/model/error/total_digits_error.rb +20 -0
- data/lib/lutaml/model/error/transform_block_not_defined_error.rb +6 -0
- data/lib/lutaml/model/error/type/invalid_value_error.rb +21 -0
- data/lib/lutaml/model/error/type/max_bound_error.rb +20 -0
- data/lib/lutaml/model/error/type/max_exclusive_error.rb +20 -0
- data/lib/lutaml/model/error/type/max_length_error.rb +20 -0
- data/lib/lutaml/model/error/type/min_bound_error.rb +20 -0
- data/lib/lutaml/model/error/type/min_exclusive_error.rb +20 -0
- data/lib/lutaml/model/error/type/min_length_error.rb +20 -0
- data/lib/lutaml/model/error/type/pattern_not_matched_error.rb +18 -0
- data/lib/lutaml/model/error/type.rb +19 -0
- data/lib/lutaml/model/error/type_error.rb +9 -0
- data/lib/lutaml/model/error/type_not_enabled_error.rb +9 -0
- data/lib/lutaml/model/error/type_only_mapping_error.rb +13 -0
- data/lib/lutaml/model/error/type_only_namespace_error.rb +12 -0
- data/lib/lutaml/model/error/undefined_attribute_error.rb +9 -0
- data/lib/lutaml/model/error/union_schema_unsupported_error.rb +11 -0
- data/lib/lutaml/model/error/unknown_adapter_type_error.rb +95 -0
- data/lib/lutaml/model/error/unknown_discriminator_error.rb +11 -0
- data/lib/lutaml/model/error/unknown_mapping_error.rb +18 -0
- data/lib/lutaml/model/error/unknown_sequence_mapping_error.rb +9 -0
- data/lib/lutaml/model/error/unknown_type_error.rb +32 -0
- data/lib/lutaml/model/error/unresolvable_type_error.rb +27 -0
- data/lib/lutaml/model/error/unsupported_version_error.rb +14 -0
- data/lib/lutaml/model/error/validation_error.rb +20 -0
- data/lib/lutaml/model/error/validation_failed_error.rb +9 -0
- data/lib/lutaml/model/error.rb +8 -0
- data/lib/lutaml/model/errors.rb +38 -0
- data/lib/lutaml/model/evolution_steps.rb +85 -0
- data/lib/lutaml/model/finalization_cache.rb +51 -0
- data/lib/lutaml/model/format_registry.rb +218 -0
- data/lib/lutaml/model/global_context.rb +476 -0
- data/lib/lutaml/model/global_register.rb +142 -0
- data/lib/lutaml/model/hash.rb +15 -0
- data/lib/lutaml/model/import_registry.rb +250 -0
- data/lib/lutaml/model/instrumentation.rb +304 -0
- data/lib/lutaml/model/json.rb +25 -0
- data/lib/lutaml/model/json_adapter.rb +8 -0
- data/lib/lutaml/model/jsonl.rb +15 -0
- data/lib/lutaml/model/liquefiable.rb +198 -0
- data/lib/lutaml/model/liquid/indexed_access.rb +33 -0
- data/lib/lutaml/model/liquid/mapping.rb +30 -0
- data/lib/lutaml/model/liquid.rb +10 -0
- data/lib/lutaml/model/lml/document.rb +109 -0
- data/lib/lutaml/model/lml/exporter.rb +328 -0
- data/lib/lutaml/model/lml/rejected_error.rb +32 -0
- data/lib/lutaml/model/lml/round_trip.rb +49 -0
- data/lib/lutaml/model/lml.rb +40 -0
- data/lib/lutaml/model/mapping/listener.rb +126 -0
- data/lib/lutaml/model/mapping/mapping.rb +209 -0
- data/lib/lutaml/model/mapping/mapping_rule.rb +673 -0
- data/lib/lutaml/model/mapping/model_mapping.rb +133 -0
- data/lib/lutaml/model/mapping/model_mapping_rule.rb +57 -0
- data/lib/lutaml/model/mapping_hash.rb +80 -0
- data/lib/lutaml/model/model_transformer.rb +101 -0
- data/lib/lutaml/model/one_entry_cache.rb +57 -0
- data/lib/lutaml/model/organization.rb +29 -0
- data/lib/lutaml/model/register/model_tree_importer.rb +88 -0
- data/lib/lutaml/model/register/namespace_binding.rb +92 -0
- data/lib/lutaml/model/register.rb +589 -0
- data/lib/lutaml/model/registrable.rb +8 -0
- data/lib/lutaml/model/render_policy.rb +166 -0
- data/lib/lutaml/model/restriction_validation.rb +437 -0
- data/lib/lutaml/model/runtime_compatibility.rb +144 -0
- data/lib/lutaml/model/schema/base_schema.rb +77 -0
- data/lib/lutaml/model/schema/class_loader.rb +59 -0
- data/lib/lutaml/model/schema/compiled_output.rb +83 -0
- data/lib/lutaml/model/schema/decorators/attribute.rb +116 -0
- data/lib/lutaml/model/schema/decorators/choices.rb +29 -0
- data/lib/lutaml/model/schema/decorators/class_definition.rb +84 -0
- data/lib/lutaml/model/schema/decorators/definition_collection.rb +97 -0
- data/lib/lutaml/model/schema/decorators.rb +15 -0
- data/lib/lutaml/model/schema/definitions/attribute.rb +32 -0
- data/lib/lutaml/model/schema/definitions/choice.rb +20 -0
- data/lib/lutaml/model/schema/definitions/facet.rb +40 -0
- data/lib/lutaml/model/schema/definitions/group_import.rb +22 -0
- data/lib/lutaml/model/schema/definitions/member_walk.rb +33 -0
- data/lib/lutaml/model/schema/definitions/model.rb +40 -0
- data/lib/lutaml/model/schema/definitions/namespace.rb +24 -0
- data/lib/lutaml/model/schema/definitions/restricted_type.rb +32 -0
- data/lib/lutaml/model/schema/definitions/sequence.rb +19 -0
- data/lib/lutaml/model/schema/definitions/simple_content.rb +22 -0
- data/lib/lutaml/model/schema/definitions/transform_facet.rb +21 -0
- data/lib/lutaml/model/schema/definitions/type_ref.rb +20 -0
- data/lib/lutaml/model/schema/definitions/union_type.rb +28 -0
- data/lib/lutaml/model/schema/definitions/xml_root.rb +20 -0
- data/lib/lutaml/model/schema/definitions.rb +24 -0
- data/lib/lutaml/model/schema/file_writer.rb +73 -0
- data/lib/lutaml/model/schema/generator/definition.rb +98 -0
- data/lib/lutaml/model/schema/generator/definitions_collection.rb +117 -0
- data/lib/lutaml/model/schema/generator/properties_collection.rb +65 -0
- data/lib/lutaml/model/schema/generator/property.rb +182 -0
- data/lib/lutaml/model/schema/generator/ref.rb +24 -0
- data/lib/lutaml/model/schema/generator.rb +15 -0
- data/lib/lutaml/model/schema/helpers/template_helper.rb +49 -0
- data/lib/lutaml/model/schema/helpers.rb +11 -0
- data/lib/lutaml/model/schema/json_schema.rb +17 -0
- data/lib/lutaml/model/schema/json_schema_parser.rb +91 -0
- data/lib/lutaml/model/schema/module_nesting.rb +31 -0
- data/lib/lutaml/model/schema/namespace_naming.rb +46 -0
- data/lib/lutaml/model/schema/registry_generator.rb +115 -0
- data/lib/lutaml/model/schema/renderer.rb +38 -0
- data/lib/lutaml/model/schema/renderers/base.rb +41 -0
- data/lib/lutaml/model/schema/renderers/mappings.rb +78 -0
- data/lib/lutaml/model/schema/renderers/member_decls.rb +121 -0
- data/lib/lutaml/model/schema/renderers/model.rb +133 -0
- data/lib/lutaml/model/schema/renderers/namespace.rb +30 -0
- data/lib/lutaml/model/schema/renderers/registration.rb +64 -0
- data/lib/lutaml/model/schema/renderers/required_files_calculator.rb +94 -0
- data/lib/lutaml/model/schema/renderers/restricted_type.rb +218 -0
- data/lib/lutaml/model/schema/renderers/union.rb +83 -0
- data/lib/lutaml/model/schema/renderers.rb +20 -0
- data/lib/lutaml/model/schema/rnc_compiler/source_resolver.rb +51 -0
- data/lib/lutaml/model/schema/rnc_compiler.rb +64 -0
- data/lib/lutaml/model/schema/rng_compiler/define_classifier.rb +94 -0
- data/lib/lutaml/model/schema/rng_compiler/element_visitor.rb +412 -0
- data/lib/lutaml/model/schema/rng_compiler/member_collector.rb +30 -0
- data/lib/lutaml/model/schema/rng_compiler/rng_helpers.rb +160 -0
- data/lib/lutaml/model/schema/rng_compiler/value_type_resolver.rb +129 -0
- data/lib/lutaml/model/schema/rng_compiler.rb +225 -0
- data/lib/lutaml/model/schema/schema_builder/nokogiri.rb +41 -0
- data/lib/lutaml/model/schema/schema_builder/oga.rb +92 -0
- data/lib/lutaml/model/schema/shared_methods.rb +24 -0
- data/lib/lutaml/model/schema/templates/model.erb +9 -0
- data/lib/lutaml/model/schema/templates.rb +164 -0
- data/lib/lutaml/model/schema/xml_compiler/element_order.rb +42 -0
- data/lib/lutaml/model/schema/xml_compiler/registry_generator.rb +51 -0
- data/lib/lutaml/model/schema/xml_compiler/spec_builder/complex_types.rb +198 -0
- data/lib/lutaml/model/schema/xml_compiler/spec_builder/members.rb +249 -0
- data/lib/lutaml/model/schema/xml_compiler/spec_builder/simple_types.rb +185 -0
- data/lib/lutaml/model/schema/xml_compiler/spec_builder.rb +186 -0
- data/lib/lutaml/model/schema/xml_compiler/supported_data_types.rb +100 -0
- data/lib/lutaml/model/schema/xml_compiler.rb +109 -0
- data/lib/lutaml/model/schema/yaml_schema.rb +17 -0
- data/lib/lutaml/model/schema.rb +88 -0
- data/lib/lutaml/model/schema_location.rb +18 -0
- data/lib/lutaml/model/sequence.rb +220 -0
- data/lib/lutaml/model/serializable.rb +46 -0
- data/lib/lutaml/model/serialization_adapter.rb +24 -0
- data/lib/lutaml/model/serialize/attribute_definition.rb +897 -0
- data/lib/lutaml/model/serialize/builder.rb +258 -0
- data/lib/lutaml/model/serialize/conversion_caching.rb +129 -0
- data/lib/lutaml/model/serialize/deserialization_context.rb +51 -0
- data/lib/lutaml/model/serialize/enum_handling.rb +171 -0
- data/lib/lutaml/model/serialize/format_conversion.rb +624 -0
- data/lib/lutaml/model/serialize/initialization.rb +825 -0
- data/lib/lutaml/model/serialize/model_import.rb +425 -0
- data/lib/lutaml/model/serialize/transformation_builder.rb +128 -0
- data/lib/lutaml/model/serialize/value_mapping.rb +173 -0
- data/lib/lutaml/model/serialize.rb +533 -0
- data/lib/lutaml/model/services/base.rb +13 -0
- data/lib/lutaml/model/services/logger.rb +57 -0
- data/lib/lutaml/model/services/rule_value_extractor.rb +95 -0
- data/lib/lutaml/model/services/transformer.rb +143 -0
- data/lib/lutaml/model/services/type/validator/number.rb +25 -0
- data/lib/lutaml/model/services/type/validator/string.rb +53 -0
- data/lib/lutaml/model/services/type/validator/symbol.rb +30 -0
- data/lib/lutaml/model/services/type/validator.rb +69 -0
- data/lib/lutaml/model/services/type.rb +9 -0
- data/lib/lutaml/model/services/validator.rb +143 -0
- data/lib/lutaml/model/services.rb +10 -0
- data/lib/lutaml/model/store.rb +239 -0
- data/lib/lutaml/model/toml.rb +40 -0
- data/lib/lutaml/model/transform/xml_transform.rb +5 -0
- data/lib/lutaml/model/transform.rb +229 -0
- data/lib/lutaml/model/transformation.rb +89 -0
- data/lib/lutaml/model/transformation_builder.rb +55 -0
- data/lib/lutaml/model/transformation_registry.rb +327 -0
- data/lib/lutaml/model/type/base64_binary.rb +58 -0
- data/lib/lutaml/model/type/boolean.rb +35 -0
- data/lib/lutaml/model/type/date.rb +75 -0
- data/lib/lutaml/model/type/date_time.rb +60 -0
- data/lib/lutaml/model/type/date_time_with_timezone.rb +28 -0
- data/lib/lutaml/model/type/date_with_timezone.rb +28 -0
- data/lib/lutaml/model/type/day_time_duration.rb +35 -0
- data/lib/lutaml/model/type/decimal.rb +64 -0
- data/lib/lutaml/model/type/duration.rb +82 -0
- data/lib/lutaml/model/type/email_address.rb +28 -0
- data/lib/lutaml/model/type/float.rb +33 -0
- data/lib/lutaml/model/type/hash.rb +74 -0
- data/lib/lutaml/model/type/hex_binary.rb +56 -0
- data/lib/lutaml/model/type/hostname.rb +30 -0
- data/lib/lutaml/model/type/integer.rb +62 -0
- data/lib/lutaml/model/type/ip_v4_address.rb +27 -0
- data/lib/lutaml/model/type/ip_v6_address.rb +47 -0
- data/lib/lutaml/model/type/metaschema_pattern.rb +34 -0
- data/lib/lutaml/model/type/non_negative_integer.rb +25 -0
- data/lib/lutaml/model/type/positive_integer.rb +25 -0
- data/lib/lutaml/model/type/qname.rb +85 -0
- data/lib/lutaml/model/type/reference.rb +76 -0
- data/lib/lutaml/model/type/string.rb +62 -0
- data/lib/lutaml/model/type/symbol.rb +67 -0
- data/lib/lutaml/model/type/time.rb +52 -0
- data/lib/lutaml/model/type/time_without_date.rb +50 -0
- data/lib/lutaml/model/type/token.rb +25 -0
- data/lib/lutaml/model/type/uninitialized_class_guard.rb +36 -0
- data/lib/lutaml/model/type/uri.rb +51 -0
- data/lib/lutaml/model/type/uri_reference.rb +29 -0
- data/lib/lutaml/model/type/uuid.rb +25 -0
- data/lib/lutaml/model/type/value.rb +364 -0
- data/lib/lutaml/model/type/year_month_duration.rb +29 -0
- data/lib/lutaml/model/type.rb +199 -0
- data/lib/lutaml/model/type_context.rb +294 -0
- data/lib/lutaml/model/type_registry.rb +165 -0
- data/lib/lutaml/model/type_resolver.rb +187 -0
- data/lib/lutaml/model/type_substitution.rb +117 -0
- data/lib/lutaml/model/uninitialized_class.rb +70 -0
- data/lib/lutaml/model/union.rb +363 -0
- data/lib/lutaml/model/utils.rb +352 -0
- data/lib/lutaml/model/validation/concerns/has_issues.rb +27 -0
- data/lib/lutaml/model/validation/context.rb +36 -0
- data/lib/lutaml/model/validation/issue.rb +62 -0
- data/lib/lutaml/model/validation/layer_result.rb +34 -0
- data/lib/lutaml/model/validation/profile.rb +66 -0
- data/lib/lutaml/model/validation/registry.rb +60 -0
- data/lib/lutaml/model/validation/remediation.rb +33 -0
- data/lib/lutaml/model/validation/remediation_result.rb +20 -0
- data/lib/lutaml/model/validation/report.rb +39 -0
- data/lib/lutaml/model/validation/rule.rb +59 -0
- data/lib/lutaml/model/validation.rb +137 -0
- data/lib/lutaml/model/validation_framework.rb +77 -0
- data/lib/lutaml/model/value_policy.rb +27 -0
- data/lib/lutaml/model/value_transformer.rb +25 -0
- data/lib/lutaml/model/version.rb +7 -0
- data/lib/lutaml/model/yaml.rb +15 -0
- data/lib/lutaml/model/yamls.rb +15 -0
- data/lib/lutaml/model.rb +309 -0
- data/lib/lutaml/rdf/context.rb +69 -0
- data/lib/lutaml/rdf/error.rb +7 -0
- data/lib/lutaml/rdf/iri.rb +44 -0
- data/lib/lutaml/rdf/language_tagged.rb +11 -0
- data/lib/lutaml/rdf/linked_data_transform.rb +249 -0
- data/lib/lutaml/rdf/literal.rb +62 -0
- data/lib/lutaml/rdf/mapping.rb +86 -0
- data/lib/lutaml/rdf/mapping_rule.rb +52 -0
- data/lib/lutaml/rdf/member_rule.rb +55 -0
- data/lib/lutaml/rdf/namespace.rb +58 -0
- data/lib/lutaml/rdf/namespace_set.rb +69 -0
- data/lib/lutaml/rdf/namespaces/dcterms_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/owl_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/rdf_namespace.rb +14 -0
- data/lib/lutaml/rdf/namespaces/rdfs_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/skos_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/xsd_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces.rb +14 -0
- data/lib/lutaml/rdf/term_definition.rb +39 -0
- data/lib/lutaml/rdf/transform.rb +45 -0
- data/lib/lutaml/rdf.rb +22 -0
- data/lib/lutaml/toml/adapter/document.rb +10 -0
- data/lib/lutaml/toml/adapter/mapping.rb +26 -0
- data/lib/lutaml/toml/adapter/mapping_rule.rb +9 -0
- data/lib/lutaml/toml/adapter/teptris_adapter.rb +14 -0
- data/lib/lutaml/toml/adapter/toml_rb_adapter.rb +32 -0
- data/lib/lutaml/toml/adapter/tomlib_adapter.rb +48 -0
- data/lib/lutaml/toml/adapter/transform.rb +9 -0
- data/lib/lutaml/toml/adapter.rb +20 -0
- data/lib/lutaml/toml/format.rb +48 -0
- data/lib/lutaml/toml/type/serializers.rb +71 -0
- data/lib/lutaml/toml.rb +7 -0
- data/lib/lutaml/turtle/adapter.rb +35 -0
- data/lib/lutaml/turtle/mapping.rb +7 -0
- data/lib/lutaml/turtle/transform.rb +250 -0
- data/lib/lutaml/turtle.rb +22 -0
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xml/adapter/adapter_helpers.rb +108 -0
- data/lib/lutaml/xml/adapter/base_adapter.rb +249 -0
- data/lib/lutaml/xml/adapter/leptris_adapter.rb +16 -0
- data/lib/lutaml/xml/adapter/namespace_data.rb +56 -0
- data/lib/lutaml/xml/adapter/namespace_uri_collector.rb +71 -0
- data/lib/lutaml/xml/adapter/nokogiri_adapter.rb +16 -0
- data/lib/lutaml/xml/adapter/oga_adapter.rb +20 -0
- data/lib/lutaml/xml/adapter/ox_adapter.rb +16 -0
- data/lib/lutaml/xml/adapter/plan_based_builder.rb +944 -0
- data/lib/lutaml/xml/adapter/rexml_adapter.rb +25 -0
- data/lib/lutaml/xml/adapter/xml_parser.rb +89 -0
- data/lib/lutaml/xml/adapter/xml_serializer.rb +334 -0
- data/lib/lutaml/xml/adapter.rb +24 -0
- data/lib/lutaml/xml/adapter_element.rb +339 -0
- data/lib/lutaml/xml/adapter_loader.rb +56 -0
- data/lib/lutaml/xml/attribute_namespace_resolver.rb +139 -0
- data/lib/lutaml/xml/blank_namespace.rb +51 -0
- data/lib/lutaml/xml/blank_namespace_handler.rb +50 -0
- data/lib/lutaml/xml/builder/base.rb +258 -0
- data/lib/lutaml/xml/builder/leptris.rb +13 -0
- data/lib/lutaml/xml/builder/nokogiri.rb +13 -0
- data/lib/lutaml/xml/builder/oga.rb +13 -0
- data/lib/lutaml/xml/builder/ox.rb +13 -0
- data/lib/lutaml/xml/builder/rexml.rb +13 -0
- data/lib/lutaml/xml/builder.rb +18 -0
- data/lib/lutaml/xml/configurable.rb +215 -0
- data/lib/lutaml/xml/data_model.rb +295 -0
- data/lib/lutaml/xml/decisions/decision.rb +120 -0
- data/lib/lutaml/xml/decisions/decision_context.rb +225 -0
- data/lib/lutaml/xml/decisions/decision_engine.rb +67 -0
- data/lib/lutaml/xml/decisions/decision_rule.rb +54 -0
- data/lib/lutaml/xml/decisions/element_prefix_resolver.rb +85 -0
- data/lib/lutaml/xml/decisions/rules/attribute_usage_rule.rb +37 -0
- data/lib/lutaml/xml/decisions/rules/default_preference_rule.rb +62 -0
- data/lib/lutaml/xml/decisions/rules/element_form_default_rule.rb +66 -0
- data/lib/lutaml/xml/decisions/rules/element_form_default_unqualified_rule.rb +73 -0
- data/lib/lutaml/xml/decisions/rules/element_form_option_rule.rb +83 -0
- data/lib/lutaml/xml/decisions/rules/explicit_option_rule.rb +57 -0
- data/lib/lutaml/xml/decisions/rules/format_preservation_rule.rb +74 -0
- data/lib/lutaml/xml/decisions/rules/hoisted_on_parent_rule.rb +60 -0
- data/lib/lutaml/xml/decisions/rules/inherit_from_parent_rule.rb +52 -0
- data/lib/lutaml/xml/decisions/rules/inherit_parent_prefix_rule.rb +69 -0
- data/lib/lutaml/xml/decisions/rules/namespace_scope_rule.rb +54 -0
- data/lib/lutaml/xml/decisions/rules/reuse_parent_prefix_rule.rb +78 -0
- data/lib/lutaml/xml/decisions/rules/used_prefix_rule.rb +70 -0
- data/lib/lutaml/xml/decisions/rules.rb +39 -0
- data/lib/lutaml/xml/decisions.rb +15 -0
- data/lib/lutaml/xml/declaration_handler.rb +115 -0
- data/lib/lutaml/xml/declaration_plan/attribute_node.rb +81 -0
- data/lib/lutaml/xml/declaration_plan/element_node.rb +101 -0
- data/lib/lutaml/xml/declaration_plan.rb +480 -0
- data/lib/lutaml/xml/declaration_plan_query.rb +105 -0
- data/lib/lutaml/xml/declaration_planner.rb +1914 -0
- data/lib/lutaml/xml/doctype_extractor.rb +51 -0
- data/lib/lutaml/xml/document.rb +385 -0
- data/lib/lutaml/xml/element.rb +108 -0
- data/lib/lutaml/xml/element_prefix_resolver.rb +50 -0
- data/lib/lutaml/xml/encoding_normalizer.rb +54 -0
- data/lib/lutaml/xml/error/invalid_namespace_error.rb +46 -0
- data/lib/lutaml/xml/error/invalid_xsd_type_error.rb +43 -0
- data/lib/lutaml/xml/error/namespace_mismatch_error.rb +53 -0
- data/lib/lutaml/xml/error/schema_validation_error.rb +25 -0
- data/lib/lutaml/xml/error/xml_configuration_error.rb +17 -0
- data/lib/lutaml/xml/error/xml_error.rb +21 -0
- data/lib/lutaml/xml/format.rb +364 -0
- data/lib/lutaml/xml/format_chooser.rb +214 -0
- data/lib/lutaml/xml/hoisting_algorithm.rb +234 -0
- data/lib/lutaml/xml/html_entities.rb +290 -0
- data/lib/lutaml/xml/leptris/element.rb +34 -0
- data/lib/lutaml/xml/leptris/native_emission.rb +295 -0
- data/lib/lutaml/xml/leptris/plan_compiler.rb +652 -0
- data/lib/lutaml/xml/leptris/plan_hydrator.rb +827 -0
- data/lib/lutaml/xml/leptris/plan_order.rb +72 -0
- data/lib/lutaml/xml/leptris/plan_serializer.rb +711 -0
- data/lib/lutaml/xml/leptris/plan_walk.rb +36 -0
- data/lib/lutaml/xml/leptris.rb +48 -0
- data/lib/lutaml/xml/listener.rb +33 -0
- data/lib/lutaml/xml/mapping.rb +1746 -0
- data/lib/lutaml/xml/mapping_rule.rb +688 -0
- data/lib/lutaml/xml/model_transform.rb +1824 -0
- data/lib/lutaml/xml/namespace.rb +445 -0
- data/lib/lutaml/xml/namespace_class_registry.rb +144 -0
- data/lib/lutaml/xml/namespace_collector.rb +649 -0
- data/lib/lutaml/xml/namespace_declaration.rb +202 -0
- data/lib/lutaml/xml/namespace_declaration_builder.rb +67 -0
- data/lib/lutaml/xml/namespace_declaration_data.rb +179 -0
- data/lib/lutaml/xml/namespace_inheritance_resolver.rb +142 -0
- data/lib/lutaml/xml/namespace_inheritance_strategy.rb +26 -0
- data/lib/lutaml/xml/namespace_needs.rb +255 -0
- data/lib/lutaml/xml/namespace_resolution_strategy.rb +230 -0
- data/lib/lutaml/xml/namespace_resolver.rb +219 -0
- data/lib/lutaml/xml/namespace_scope_config.rb +110 -0
- data/lib/lutaml/xml/namespace_type_resolver.rb +135 -0
- data/lib/lutaml/xml/namespace_usage.rb +121 -0
- data/lib/lutaml/xml/nested_collection_attribute.rb +95 -0
- data/lib/lutaml/xml/nokogiri/element.rb +34 -0
- data/lib/lutaml/xml/nokogiri.rb +10 -0
- data/lib/lutaml/xml/oga/element.rb +15 -0
- data/lib/lutaml/xml/oga.rb +10 -0
- data/lib/lutaml/xml/ox/element.rb +15 -0
- data/lib/lutaml/xml/ox.rb +10 -0
- data/lib/lutaml/xml/parse_session.rb +139 -0
- data/lib/lutaml/xml/parsed_namespace_declaration.rb +129 -0
- data/lib/lutaml/xml/parsed_namespace_set.rb +149 -0
- data/lib/lutaml/xml/polymorphic_value_handler.rb +41 -0
- data/lib/lutaml/xml/qualified_inheritance_strategy.rb +27 -0
- data/lib/lutaml/xml/rexml/element.rb +15 -0
- data/lib/lutaml/xml/rexml.rb +10 -0
- data/lib/lutaml/xml/schema/builder/nokogiri.rb +41 -0
- data/lib/lutaml/xml/schema/builder/oga.rb +92 -0
- data/lib/lutaml/xml/schema/builder.rb +59 -0
- data/lib/lutaml/xml/schema/builtin_types.rb +112 -0
- data/lib/lutaml/xml/schema/relaxng_schema.rb +83 -0
- data/lib/lutaml/xml/schema/xsd/all.rb +31 -0
- data/lib/lutaml/xml/schema/xsd/annotation.rb +31 -0
- data/lib/lutaml/xml/schema/xsd/any.rb +33 -0
- data/lib/lutaml/xml/schema/xsd/any_attribute.rb +29 -0
- data/lib/lutaml/xml/schema/xsd/appinfo.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/attribute.rb +78 -0
- data/lib/lutaml/xml/schema/xsd/attribute_group.rb +89 -0
- data/lib/lutaml/xml/schema/xsd/base.rb +270 -0
- data/lib/lutaml/xml/schema/xsd/choice.rb +68 -0
- data/lib/lutaml/xml/schema/xsd/complex_content.rb +39 -0
- data/lib/lutaml/xml/schema/xsd/complex_type.rb +159 -0
- data/lib/lutaml/xml/schema/xsd/documentation.rb +26 -0
- data/lib/lutaml/xml/schema/xsd/element.rb +117 -0
- data/lib/lutaml/xml/schema/xsd/enumeration.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb +142 -0
- data/lib/lutaml/xml/schema/xsd/errors/error_context.rb +67 -0
- data/lib/lutaml/xml/schema/xsd/errors/message_builder.rb +103 -0
- data/lib/lutaml/xml/schema/xsd/errors/suggestion.rb +67 -0
- data/lib/lutaml/xml/schema/xsd/errors/troubleshooters/namespace_troubleshooter.rb +96 -0
- data/lib/lutaml/xml/schema/xsd/errors/troubleshooters/troubleshooting_handler.rb +70 -0
- data/lib/lutaml/xml/schema/xsd/errors.rb +148 -0
- data/lib/lutaml/xml/schema/xsd/extension_complex_content.rb +63 -0
- data/lib/lutaml/xml/schema/xsd/extension_simple_content.rb +48 -0
- data/lib/lutaml/xml/schema/xsd/field.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/file_validation_result.rb +55 -0
- data/lib/lutaml/xml/schema/xsd/fraction_digits.rb +29 -0
- data/lib/lutaml/xml/schema/xsd/glob.rb +105 -0
- data/lib/lutaml/xml/schema/xsd/group.rb +79 -0
- data/lib/lutaml/xml/schema/xsd/import.rb +33 -0
- data/lib/lutaml/xml/schema/xsd/include.rb +31 -0
- data/lib/lutaml/xml/schema/xsd/key.rb +32 -0
- data/lib/lutaml/xml/schema/xsd/keyref.rb +34 -0
- data/lib/lutaml/xml/schema/xsd/length.rb +27 -0
- data/lib/lutaml/xml/schema/xsd/list.rb +29 -0
- data/lib/lutaml/xml/schema/xsd/max_exclusive.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/max_inclusive.rb +23 -0
- data/lib/lutaml/xml/schema/xsd/max_length.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/min_exclusive.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/min_inclusive.rb +23 -0
- data/lib/lutaml/xml/schema/xsd/min_length.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/namespace_mapping.rb +37 -0
- data/lib/lutaml/xml/schema/xsd/namespace_uri_remapping.rb +79 -0
- data/lib/lutaml/xml/schema/xsd/notation.rb +31 -0
- data/lib/lutaml/xml/schema/xsd/pattern.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/redefine.rb +35 -0
- data/lib/lutaml/xml/schema/xsd/restriction_complex_content.rb +56 -0
- data/lib/lutaml/xml/schema/xsd/restriction_simple_content.rb +84 -0
- data/lib/lutaml/xml/schema/xsd/restriction_simple_type.rb +64 -0
- data/lib/lutaml/xml/schema/xsd/schema.rb +379 -0
- data/lib/lutaml/xml/schema/xsd/schema_file_validation_results.rb +55 -0
- data/lib/lutaml/xml/schema/xsd/schema_location_mapping.rb +74 -0
- data/lib/lutaml/xml/schema/xsd/schema_name_resolver.rb +32 -0
- data/lib/lutaml/xml/schema/xsd/schema_path.rb +207 -0
- data/lib/lutaml/xml/schema/xsd/schema_validator.rb +259 -0
- data/lib/lutaml/xml/schema/xsd/selector.rb +27 -0
- data/lib/lutaml/xml/schema/xsd/sequence.rb +68 -0
- data/lib/lutaml/xml/schema/xsd/serialized_schema.rb +185 -0
- data/lib/lutaml/xml/schema/xsd/simple_content.rb +61 -0
- data/lib/lutaml/xml/schema/xsd/simple_type.rb +37 -0
- data/lib/lutaml/xml/schema/xsd/total_digits.rb +29 -0
- data/lib/lutaml/xml/schema/xsd/type_index_entry.rb +40 -0
- data/lib/lutaml/xml/schema/xsd/type_resolution_result.rb +112 -0
- data/lib/lutaml/xml/schema/xsd/union.rb +30 -0
- data/lib/lutaml/xml/schema/xsd/unique.rb +31 -0
- data/lib/lutaml/xml/schema/xsd/validation_error.rb +48 -0
- data/lib/lutaml/xml/schema/xsd/validation_result.rb +86 -0
- data/lib/lutaml/xml/schema/xsd/version.rb +11 -0
- data/lib/lutaml/xml/schema/xsd/white_space.rb +27 -0
- data/lib/lutaml/xml/schema/xsd.rb +164 -0
- data/lib/lutaml/xml/schema/xsd_namespace.rb +29 -0
- data/lib/lutaml/xml/schema/xsd_schema.rb +1002 -0
- data/lib/lutaml/xml/schema.rb +16 -0
- data/lib/lutaml/xml/schema_location.rb +155 -0
- data/lib/lutaml/xml/serialization/collection_ext.rb +61 -0
- data/lib/lutaml/xml/serialization/format_conversion.rb +433 -0
- data/lib/lutaml/xml/serialization/instance_methods.rb +323 -0
- data/lib/lutaml/xml/serialization/model_import_ext.rb +40 -0
- data/lib/lutaml/xml/serialization.rb +15 -0
- data/lib/lutaml/xml/shared_dsl.rb +119 -0
- data/lib/lutaml/xml/transform.rb +6 -0
- data/lib/lutaml/xml/transformation/custom_method_wrapper.rb +258 -0
- data/lib/lutaml/xml/transformation/element_builder.rb +697 -0
- data/lib/lutaml/xml/transformation/order_reconciler.rb +282 -0
- data/lib/lutaml/xml/transformation/ordered_applier.rb +529 -0
- data/lib/lutaml/xml/transformation/rule_applier.rb +403 -0
- data/lib/lutaml/xml/transformation/rule_compiler.rb +556 -0
- data/lib/lutaml/xml/transformation/skip_logic.rb +70 -0
- data/lib/lutaml/xml/transformation/value_serializer.rb +137 -0
- data/lib/lutaml/xml/transformation.rb +454 -0
- data/lib/lutaml/xml/transformation_builder.rb +28 -0
- data/lib/lutaml/xml/transformation_support.rb +15 -0
- data/lib/lutaml/xml/type/configurable.rb +153 -0
- data/lib/lutaml/xml/type/serializers.rb +105 -0
- data/lib/lutaml/xml/type/value_xml_mapping.rb +94 -0
- data/lib/lutaml/xml/type_namespace/collector.rb +101 -0
- data/lib/lutaml/xml/type_namespace/declaration.rb +61 -0
- data/lib/lutaml/xml/type_namespace/planner.rb +121 -0
- data/lib/lutaml/xml/type_namespace/reference.rb +71 -0
- data/lib/lutaml/xml/type_namespace/resolver.rb +43 -0
- data/lib/lutaml/xml/type_namespace.rb +13 -0
- data/lib/lutaml/xml/type_namespace_resolver.rb +76 -0
- data/lib/lutaml/xml/unqualified_inheritance_strategy.rb +34 -0
- data/lib/lutaml/xml/w3c/registration.rb +66 -0
- data/lib/lutaml/xml/w3c.rb +398 -0
- data/lib/lutaml/xml/xml_attribute.rb +58 -0
- data/lib/lutaml/xml/xml_element.rb +498 -0
- data/lib/lutaml/xml/xml_namespace.rb +72 -0
- data/lib/lutaml/xml/xml_orderable.rb +17 -0
- data/lib/lutaml/xml/xsd_validator.rb +66 -0
- data/lib/lutaml/xml.rb +7 -0
- data/lib/lutaml/yaml/adapter/document.rb +12 -0
- data/lib/lutaml/yaml/adapter/mapping.rb +17 -0
- data/lib/lutaml/yaml/adapter/mapping_rule.rb +9 -0
- data/lib/lutaml/yaml/adapter/standard_adapter.rb +35 -0
- data/lib/lutaml/yaml/adapter/transform.rb +9 -0
- data/lib/lutaml/yaml/adapter/yeptris_adapter.rb +107 -0
- data/lib/lutaml/yaml/adapter.rb +18 -0
- data/lib/lutaml/yaml/format.rb +31 -0
- data/lib/lutaml/yaml/schema/yaml_schema.rb +65 -0
- data/lib/lutaml/yaml/schema.rb +9 -0
- data/lib/lutaml/yaml/type/serializers.rb +60 -0
- data/lib/lutaml/yaml.rb +7 -0
- data/lib/lutaml/yamlld/adapter.rb +20 -0
- data/lib/lutaml/yamlld.rb +25 -0
- data/lib/lutaml/yamls/adapter/document.rb +14 -0
- data/lib/lutaml/yamls/adapter/mapping.rb +30 -0
- data/lib/lutaml/yamls/adapter/mapping_rule.rb +9 -0
- data/lib/lutaml/yamls/adapter/standard_adapter.rb +56 -0
- data/lib/lutaml/yamls/adapter/transform.rb +124 -0
- data/lib/lutaml/yamls/adapter/yamls_sequence.rb +20 -0
- data/lib/lutaml/yamls/adapter/yamls_sequence_rule.rb +48 -0
- data/lib/lutaml/yamls/adapter.rb +15 -0
- data/lib/lutaml/yamls/format.rb +22 -0
- data/lib/lutaml/yamls.rb +7 -0
- data/lib/lutaml.rb +11 -5
- data/lib/tasks/benchmark_runner.rb +161 -0
- data/lib/tasks/memory_profile.rb +176 -0
- data/lib/tasks/performance.rake +80 -0
- data/lib/tasks/performance_benchmark.rb +499 -0
- data/lib/tasks/performance_comparator.rb +130 -0
- data/lib/tasks/performance_helpers.rb +149 -0
- data/lib/tasks/performance_probe.rake +33 -0
- data/lib/tasks/performance_probe.rb +106 -0
- data/lib/tasks/performance_probe_plan_walk.rb +58 -0
- data/lib/tasks/performance_probe_xml.rb +54 -0
- data/lib/tasks/xml_compiler_benchmark.rb +226 -0
- data/lib/tasks/xml_optimization_benchmark.rb +178 -0
- data/lutaml.gemspec +16 -8
- metadata +902 -83
- data/.github/workflows/docs.yml +0 -86
- data/.github/workflows/links.yml +0 -113
- data/.github/workflows/rake.yml +0 -23
- data/.github/workflows/release.yml +0 -37
- data/.gitignore +0 -29
- data/CLAUDE.md +0 -62
- data/docs/.github/workflows/docs.yml +0 -66
- data/docs/.github/workflows/links.yml +0 -78
- data/docs/CONTINUATION_PLAN.md +0 -168
- data/docs/Gemfile +0 -13
- data/docs/MIGRATION_GUIDE.md +0 -202
- data/docs/README.md +0 -252
- data/docs/REFACTOR_PLAN.md +0 -214
- data/docs/_config.yml +0 -144
- data/docs/_guides/cli-usage.adoc +0 -43
- data/docs/_guides/diagram-generation.adoc +0 -316
- data/docs/_guides/index.adoc +0 -136
- data/docs/_guides/parsing/express-parsing.adoc +0 -42
- data/docs/_guides/parsing/index.adoc +0 -78
- data/docs/_guides/parsing/qea-parsing.adoc +0 -47
- data/docs/_guides/parsing/xmi-parsing.adoc +0 -40
- data/docs/_guides/repository-management.adoc +0 -44
- data/docs/_guides/sysml-modeling.adoc +0 -37
- data/docs/_guides/uml-modeling.adoc +0 -115
- data/docs/_pages/concepts/diagram-generation.adoc +0 -337
- data/docs/_pages/concepts/lur-format.adoc +0 -711
- data/docs/_pages/concepts/qea-parsing.adoc +0 -418
- data/docs/_pages/concepts/uml-models.adoc +0 -43
- data/docs/_pages/core/architecture.adoc +0 -329
- data/docs/_pages/core/installation.adoc +0 -321
- data/docs/_pages/core/overview.adoc +0 -197
- data/docs/_pages/index.adoc +0 -49
- data/docs/_pages/uml-syntax.adoc +0 -1011
- data/docs/_references/api/parsers.adoc +0 -61
- data/docs/_references/api/presenters.adoc +0 -43
- data/docs/_references/api/repository.adoc +0 -67
- data/docs/_references/cli/commands.adoc +0 -72
- data/docs/_references/configuration/diagram-styles.adoc +0 -716
- data/docs/_references/configuration/index.adoc +0 -53
- data/docs/_references/configuration/package-metadata.adoc +0 -416
- data/docs/_references/formats/index.adoc +0 -43
- data/docs/_references/formats/lur-format.adoc +0 -39
- data/docs/_references/formats/lutaml-syntax.adoc +0 -379
- data/docs/_references/formats/qea-structure.adoc +0 -1364
- data/docs/_references/index.adoc +0 -198
- data/docs/_tutorials/documentation-site.adoc +0 -47
- data/docs/_tutorials/first-lur-package.adoc +0 -45
- data/docs/_tutorials/generating-diagrams.adoc +0 -42
- data/docs/_tutorials/getting-started.adoc +0 -45
- data/docs/_tutorials/index.adoc +0 -100
- data/docs/_tutorials/querying-models.adoc +0 -44
- data/docs/examples/build_package.rb +0 -12
- data/docs/examples/build_site.rb +0 -12
- data/docs/examples/city_model.rb +0 -21
- data/docs/examples/present_class.rb +0 -10
- data/docs/examples/query_model.rb +0 -12
- data/docs/examples/render_diagram.rb +0 -11
- data/docs/index.adoc +0 -64
- data/docs/lychee.toml +0 -50
- data/lib/lutaml/express/parsers/exp.rb +0 -28
- data/lib/lutaml/express.rb +0 -10
- data/scripts/check-site-urls.rb +0 -54
- data/scripts/check-vendor-link.py +0 -64
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rexml/parseexception"
|
|
4
|
+
require "rexml/undefinednamespaceexception"
|
|
5
|
+
require "rexml/security"
|
|
6
|
+
require "rexml/source"
|
|
7
|
+
require "set"
|
|
8
|
+
require "strscan"
|
|
9
|
+
|
|
10
|
+
module REXML
|
|
11
|
+
module Parsers
|
|
12
|
+
unless [].respond_to?(:tally)
|
|
13
|
+
module EnumerableTally
|
|
14
|
+
refine Enumerable do
|
|
15
|
+
def tally
|
|
16
|
+
counts = {}
|
|
17
|
+
each do |item|
|
|
18
|
+
counts[item] ||= 0
|
|
19
|
+
counts[item] += 1
|
|
20
|
+
end
|
|
21
|
+
counts
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
using EnumerableTally
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if StringScanner::Version < "3.0.8"
|
|
29
|
+
module StringScannerCaptures
|
|
30
|
+
refine StringScanner do
|
|
31
|
+
def captures
|
|
32
|
+
values_at(*(1...size))
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
using StringScannerCaptures
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# = Using the Pull Parser
|
|
40
|
+
# <em>This API is experimental, and subject to change.</em>
|
|
41
|
+
# parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
|
|
42
|
+
# while parser.has_next?
|
|
43
|
+
# res = parser.next
|
|
44
|
+
# puts res[1]['att'] if res.start_tag? and res[0] == 'b'
|
|
45
|
+
# end
|
|
46
|
+
# See the PullEvent class for information on the content of the results.
|
|
47
|
+
# The data is identical to the arguments passed for the various events to
|
|
48
|
+
# the StreamListener API.
|
|
49
|
+
#
|
|
50
|
+
# Notice that:
|
|
51
|
+
# parser = PullParser.new( "<a>BAD DOCUMENT" )
|
|
52
|
+
# while parser.has_next?
|
|
53
|
+
# res = parser.next
|
|
54
|
+
# raise res[1] if res.error?
|
|
55
|
+
# end
|
|
56
|
+
#
|
|
57
|
+
# Nat Price gave me some good ideas for the API.
|
|
58
|
+
class BaseParser
|
|
59
|
+
LETTER = "A-Za-z"
|
|
60
|
+
DIGIT = "0-9"
|
|
61
|
+
|
|
62
|
+
COMBININGCHAR = "" # TODO
|
|
63
|
+
EXTENDER = "" # TODO
|
|
64
|
+
|
|
65
|
+
NCNAME_STR = "[#{LETTER}_][-A-Za-z0-9._#{COMBININGCHAR}#{EXTENDER}]*".freeze
|
|
66
|
+
QNAME_STR = "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})".freeze
|
|
67
|
+
QNAME = /(#{QNAME_STR})/
|
|
68
|
+
|
|
69
|
+
# Just for backward compatibility. For example, kramdown uses this.
|
|
70
|
+
# It's not used in REXML.
|
|
71
|
+
UNAME_STR = "(?:#{NCNAME_STR}:)?#{NCNAME_STR}".freeze
|
|
72
|
+
|
|
73
|
+
NAMECHAR = '[\-\w\.:]'
|
|
74
|
+
NAME = "([\\w:]#{NAMECHAR}*)".freeze
|
|
75
|
+
NMTOKEN = "(?:#{NAMECHAR})+".freeze
|
|
76
|
+
NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*".freeze
|
|
77
|
+
REFERENCE = "&(?:#{NAME};|#\\d+;|#x[0-9a-fA-F]+;)".freeze
|
|
78
|
+
REFERENCE_RE = /#{REFERENCE}/
|
|
79
|
+
|
|
80
|
+
DOCTYPE_START = /^\s*<!DOCTYPE\s/um
|
|
81
|
+
DOCTYPE_END = /^\s*\]\s*>/um
|
|
82
|
+
ATTRIBUTE_PATTERN = /\s*(#{QNAME_STR})\s*=\s*(["'])(.*?)\4/um
|
|
83
|
+
COMMENT_START = /^<!--/u
|
|
84
|
+
COMMENT_PATTERN = /<!--(.*?)-->/um
|
|
85
|
+
CDATA_START = /^<!\[CDATA\[/u
|
|
86
|
+
CDATA_END = /^\s*\]\s*>/um
|
|
87
|
+
CDATA_PATTERN = /<!\[CDATA\[(.*?)\]\]>/um
|
|
88
|
+
XMLDECL_START = /^<\?xml\s/u
|
|
89
|
+
XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>/um
|
|
90
|
+
INSTRUCTION_START = /^<\?/u
|
|
91
|
+
INSTRUCTION_PATTERN = /<\?#{NAME}(\s+.*?)?\?>/um
|
|
92
|
+
TAG_MATCH = /^<((?:#{QNAME_STR}))/um
|
|
93
|
+
CLOSE_MATCH = /^\s*<\/(#{QNAME_STR})\s*>/um
|
|
94
|
+
|
|
95
|
+
VERSION = /\bversion\s*=\s*["'](.*?)['"]/um
|
|
96
|
+
ENCODING = /\bencoding\s*=\s*["'](.*?)['"]/um
|
|
97
|
+
STANDALONE = /\bstandalone\s*=\s*["'](.*?)['"]/um
|
|
98
|
+
|
|
99
|
+
ENTITY_START = /^\s*<!ENTITY/
|
|
100
|
+
ELEMENTDECL_START = /^\s*<!ELEMENT/um
|
|
101
|
+
ELEMENTDECL_PATTERN = /^\s*(<!ELEMENT.*?)>/um
|
|
102
|
+
SYSTEMENTITY = /^\s*(%.*?;)\s*$/um
|
|
103
|
+
ENUMERATION = "\\(\\s*#{NMTOKEN}(?:\\s*\\|\\s*#{NMTOKEN})*\\s*\\)".freeze
|
|
104
|
+
NOTATIONTYPE = "NOTATION\\s+\\(\\s*#{NAME}(?:\\s*\\|\\s*#{NAME})*\\s*\\)".freeze
|
|
105
|
+
ENUMERATEDTYPE = "(?:(?:#{NOTATIONTYPE})|(?:#{ENUMERATION}))".freeze
|
|
106
|
+
ATTTYPE = "(CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS|#{ENUMERATEDTYPE})".freeze
|
|
107
|
+
ATTVALUE = "(?:\"((?:[^<&\"]|#{REFERENCE})*)\")|(?:'((?:[^<&']|#{REFERENCE})*)')".freeze
|
|
108
|
+
DEFAULTDECL = "(#REQUIRED|#IMPLIED|(?:(#FIXED\\s+)?#{ATTVALUE}))".freeze
|
|
109
|
+
ATTDEF = "\\s+#{NAME}\\s+#{ATTTYPE}\\s+#{DEFAULTDECL}".freeze
|
|
110
|
+
ATTDEF_RE = /#{ATTDEF}/
|
|
111
|
+
ATTLISTDECL_START = /^\s*<!ATTLIST/um
|
|
112
|
+
ATTLISTDECL_PATTERN = /^\s*<!ATTLIST\s+#{NAME}(?:#{ATTDEF})*\s*>/um
|
|
113
|
+
|
|
114
|
+
TEXT_PATTERN = /^([^<]*)/um
|
|
115
|
+
|
|
116
|
+
# Entity constants
|
|
117
|
+
PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#"
|
|
118
|
+
SYSTEMLITERAL = %{((?:"[^"]*")|(?:'[^']*'))}
|
|
119
|
+
PUBIDLITERAL = %{("[#{PUBIDCHAR}']*"|'[#{PUBIDCHAR}]*')}.freeze
|
|
120
|
+
EXTERNALID = "(?:(?:(SYSTEM)\\s+#{SYSTEMLITERAL})|(?:(PUBLIC)\\s+#{PUBIDLITERAL}\\s+#{SYSTEMLITERAL}))".freeze
|
|
121
|
+
NDATADECL = "\\s+NDATA\\s+#{NAME}".freeze
|
|
122
|
+
PEREFERENCE = "%#{NAME};".freeze
|
|
123
|
+
ENTITYVALUE = %{((?:"(?:[^%&"]|#{PEREFERENCE}|#{REFERENCE})*")|(?:'([^%&']|#{PEREFERENCE}|#{REFERENCE})*'))}.freeze
|
|
124
|
+
PEDEF = "(?:#{ENTITYVALUE}|#{EXTERNALID})".freeze
|
|
125
|
+
ENTITYDEF = "(?:#{ENTITYVALUE}|(?:#{EXTERNALID}(#{NDATADECL})?))".freeze
|
|
126
|
+
PEDECL = "<!ENTITY\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>".freeze
|
|
127
|
+
GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>".freeze
|
|
128
|
+
ENTITYDECL = /\s*(?:#{GEDECL})|\s*(?:#{PEDECL})/um
|
|
129
|
+
|
|
130
|
+
NOTATIONDECL_START = /^\s*<!NOTATION/um
|
|
131
|
+
EXTERNAL_ID_PUBLIC = /^\s*PUBLIC\s+#{PUBIDLITERAL}\s+#{SYSTEMLITERAL}\s*/um
|
|
132
|
+
EXTERNAL_ID_SYSTEM = /^\s*SYSTEM\s+#{SYSTEMLITERAL}\s*/um
|
|
133
|
+
PUBLIC_ID = /^\s*PUBLIC\s+#{PUBIDLITERAL}\s*/um
|
|
134
|
+
|
|
135
|
+
EREFERENCE = /&(?!#{NAME};)/
|
|
136
|
+
|
|
137
|
+
DEFAULT_ENTITIES = {
|
|
138
|
+
"gt" => [/>/, ">", ">", />/],
|
|
139
|
+
"lt" => [/</, "<", "<", /</],
|
|
140
|
+
"quot" => [/"/, """, '"', /"/],
|
|
141
|
+
"apos" => [/'/, "'", "'", /'/],
|
|
142
|
+
}.freeze
|
|
143
|
+
|
|
144
|
+
module Private
|
|
145
|
+
PEREFERENCE_PATTERN = /#{PEREFERENCE}/um
|
|
146
|
+
TAG_PATTERN = /((?:#{QNAME_STR}))\s*/um
|
|
147
|
+
CLOSE_PATTERN = /(#{QNAME_STR})\s*>/um
|
|
148
|
+
EQUAL_PATTERN = /\s*=\s*/um
|
|
149
|
+
ATTLISTDECL_END = /\s+#{NAME}(?:#{ATTDEF})*\s*>/um
|
|
150
|
+
NAME_PATTERN = /#{NAME}/um
|
|
151
|
+
GEDECL_PATTERN = "\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>".freeze
|
|
152
|
+
PEDECL_PATTERN = "\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>".freeze
|
|
153
|
+
ENTITYDECL_PATTERN = /(?:#{GEDECL_PATTERN})|(?:#{PEDECL_PATTERN})/um
|
|
154
|
+
CARRIAGE_RETURN_NEWLINE_PATTERN = /\r\n?/
|
|
155
|
+
CHARACTER_REFERENCES = /&#((?:\d+)|(?:x[a-fA-F0-9]+));/
|
|
156
|
+
DEFAULT_ENTITIES_PATTERNS = {}
|
|
157
|
+
default_entities = ["gt", "lt", "quot", "apos", "amp"]
|
|
158
|
+
default_entities.each do |term|
|
|
159
|
+
DEFAULT_ENTITIES_PATTERNS[term] = /&#{term};/
|
|
160
|
+
end
|
|
161
|
+
DEFAULT_ENTITIES_PATTERNS.freeze
|
|
162
|
+
XML_PREFIXED_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
|
|
163
|
+
end
|
|
164
|
+
private_constant :Private
|
|
165
|
+
|
|
166
|
+
def initialize(source)
|
|
167
|
+
self.stream = source
|
|
168
|
+
@listeners = []
|
|
169
|
+
@prefixes = Set.new
|
|
170
|
+
@entity_expansion_count = 0
|
|
171
|
+
@entity_expansion_limit = Security.entity_expansion_limit
|
|
172
|
+
@entity_expansion_text_limit = Security.entity_expansion_text_limit
|
|
173
|
+
@source.ensure_buffer
|
|
174
|
+
@version = nil
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def add_listener(listener)
|
|
178
|
+
@listeners << listener
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
attr_reader :source, :entity_expansion_count
|
|
182
|
+
attr_writer :entity_expansion_limit, :entity_expansion_text_limit
|
|
183
|
+
|
|
184
|
+
def stream=(source)
|
|
185
|
+
@source = SourceFactory.create_from(source)
|
|
186
|
+
reset
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def reset
|
|
190
|
+
@closed = nil
|
|
191
|
+
@have_root = false
|
|
192
|
+
@document_status = nil
|
|
193
|
+
@tags = []
|
|
194
|
+
@stack = []
|
|
195
|
+
@entities = []
|
|
196
|
+
@namespaces = { "xml" => Private::XML_PREFIXED_NAMESPACE }
|
|
197
|
+
@namespaces_restore_stack = []
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def position
|
|
201
|
+
if @source.respond_to? :position
|
|
202
|
+
@source.position
|
|
203
|
+
else
|
|
204
|
+
# FIXME
|
|
205
|
+
0
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Returns true if there are no more events
|
|
210
|
+
def empty?
|
|
211
|
+
(@source.empty? and @stack.empty?)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Returns true if there are more events. Synonymous with !empty?
|
|
215
|
+
def has_next?
|
|
216
|
+
!(@source.empty? and @stack.empty?)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Push an event back on the head of the stream. This method
|
|
220
|
+
# has (theoretically) infinite depth.
|
|
221
|
+
def unshift(token)
|
|
222
|
+
@stack.unshift(token)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Peek at the +depth+ event in the stack. The first element on the stack
|
|
226
|
+
# is at depth 0. If +depth+ is -1, will parse to the end of the input
|
|
227
|
+
# stream and return the last event, which is always :end_document.
|
|
228
|
+
# Be aware that this causes the stream to be parsed up to the +depth+
|
|
229
|
+
# event, so you can effectively pre-parse the entire document (pull the
|
|
230
|
+
# entire thing into memory) using this method.
|
|
231
|
+
def peek(depth = 0)
|
|
232
|
+
raise %[Illegal argument "#{depth}"] if depth < -1
|
|
233
|
+
|
|
234
|
+
temp = []
|
|
235
|
+
if depth == -1
|
|
236
|
+
temp.push(pull) until empty?
|
|
237
|
+
else
|
|
238
|
+
while @stack.size + temp.size < depth + 1
|
|
239
|
+
temp.push(pull)
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
@stack += temp if temp.size.positive?
|
|
243
|
+
@stack[depth]
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Returns the next event. This is a +PullEvent+ object.
|
|
247
|
+
def pull
|
|
248
|
+
@source.drop_parsed_content
|
|
249
|
+
|
|
250
|
+
pull_event.tap do |event|
|
|
251
|
+
@listeners.each do |listener|
|
|
252
|
+
listener.receive event
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def pull_event
|
|
258
|
+
if @closed
|
|
259
|
+
x = @closed
|
|
260
|
+
@closed = nil
|
|
261
|
+
return [:end_element, x]
|
|
262
|
+
end
|
|
263
|
+
if empty?
|
|
264
|
+
if @document_status == :in_doctype
|
|
265
|
+
raise ParseException.new("Malformed DOCTYPE: unclosed", @source)
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
unless @tags.empty?
|
|
269
|
+
path = "/#{@tags.join('/')}"
|
|
270
|
+
raise ParseException.new("Missing end tag for '#{path}'", @source)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
unless @document_status == :in_element
|
|
274
|
+
raise ParseException.new("Malformed XML: No root element", @source)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
return [:end_document]
|
|
278
|
+
end
|
|
279
|
+
return @stack.shift if @stack.size.positive?
|
|
280
|
+
|
|
281
|
+
# STDERR.puts @source.encoding
|
|
282
|
+
# STDERR.puts "BUFFER = #{@source.buffer.inspect}"
|
|
283
|
+
|
|
284
|
+
@source.ensure_buffer
|
|
285
|
+
if @document_status == nil
|
|
286
|
+
start_position = @source.position
|
|
287
|
+
if @source.match?("<?", true)
|
|
288
|
+
return process_instruction
|
|
289
|
+
elsif @source.match?("<!", true)
|
|
290
|
+
if @source.match?("--", true)
|
|
291
|
+
return [:comment, process_comment]
|
|
292
|
+
elsif @source.match?("DOCTYPE", true)
|
|
293
|
+
base_error_message = "Malformed DOCTYPE"
|
|
294
|
+
unless @source.skip_spaces
|
|
295
|
+
message = if @source.match?(">")
|
|
296
|
+
"#{base_error_message}: name is missing"
|
|
297
|
+
else
|
|
298
|
+
"#{base_error_message}: invalid name"
|
|
299
|
+
end
|
|
300
|
+
@source.position = start_position
|
|
301
|
+
raise REXML::ParseException.new(message, @source)
|
|
302
|
+
end
|
|
303
|
+
name = parse_name(base_error_message)
|
|
304
|
+
@source.skip_spaces
|
|
305
|
+
if @source.match?("[", true)
|
|
306
|
+
id = [nil, nil, nil]
|
|
307
|
+
@document_status = :in_doctype
|
|
308
|
+
elsif @source.match?(">", true)
|
|
309
|
+
id = [nil, nil, nil]
|
|
310
|
+
@document_status = :after_doctype
|
|
311
|
+
@source.ensure_buffer
|
|
312
|
+
else
|
|
313
|
+
id = parse_id(base_error_message,
|
|
314
|
+
accept_external_id: true,
|
|
315
|
+
accept_public_id: false)
|
|
316
|
+
if id[0] == "SYSTEM"
|
|
317
|
+
# For backward compatibility
|
|
318
|
+
id[1] = id[2]
|
|
319
|
+
id[2] = nil
|
|
320
|
+
end
|
|
321
|
+
@source.skip_spaces
|
|
322
|
+
if @source.match?("[", true)
|
|
323
|
+
@document_status = :in_doctype
|
|
324
|
+
elsif @source.match?(">", true)
|
|
325
|
+
@document_status = :after_doctype
|
|
326
|
+
@source.ensure_buffer
|
|
327
|
+
else
|
|
328
|
+
message = "#{base_error_message}: garbage after external ID"
|
|
329
|
+
raise REXML::ParseException.new(message, @source)
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
args = [:start_doctype, name, *id]
|
|
333
|
+
if @document_status == :after_doctype
|
|
334
|
+
@source.skip_spaces
|
|
335
|
+
@stack << [:end_doctype]
|
|
336
|
+
end
|
|
337
|
+
return args
|
|
338
|
+
else
|
|
339
|
+
message = "Invalid XML"
|
|
340
|
+
raise REXML::ParseException.new(message, @source)
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
end
|
|
344
|
+
if @document_status == :in_doctype
|
|
345
|
+
@source.skip_spaces
|
|
346
|
+
start_position = @source.position
|
|
347
|
+
if @source.match?("<!", true)
|
|
348
|
+
if @source.match?("ELEMENT", true)
|
|
349
|
+
md = @source.match(/(.*?)>/um, true)
|
|
350
|
+
if md.nil?
|
|
351
|
+
raise REXML::ParseException.new("Bad ELEMENT declaration!",
|
|
352
|
+
@source)
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
return [:elementdecl, "<!ELEMENT#{md[1]}"]
|
|
356
|
+
elsif @source.match?("ENTITY", true)
|
|
357
|
+
match_data = @source.match(Private::ENTITYDECL_PATTERN, true)
|
|
358
|
+
unless match_data
|
|
359
|
+
raise REXML::ParseException.new("Malformed entity declaration",
|
|
360
|
+
@source)
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
match = [:entitydecl, *match_data.captures.compact]
|
|
364
|
+
ref = false
|
|
365
|
+
if match[1] == "%"
|
|
366
|
+
ref = true
|
|
367
|
+
match.delete_at 1
|
|
368
|
+
end
|
|
369
|
+
# Now we have to sort out what kind of entity reference this is
|
|
370
|
+
case match[2]
|
|
371
|
+
when "SYSTEM"
|
|
372
|
+
# External reference
|
|
373
|
+
match[3] = match[3][1..-2] # PUBID
|
|
374
|
+
match.delete_at(4) if match.size > 4 # Chop out NDATA decl
|
|
375
|
+
# match is [ :entity, name, SYSTEM, pubid(, ndata)? ]
|
|
376
|
+
when "PUBLIC"
|
|
377
|
+
# External reference
|
|
378
|
+
match[3] = match[3][1..-2] # PUBID
|
|
379
|
+
match[4] = match[4][1..-2] # HREF
|
|
380
|
+
match.delete_at(5) if match.size > 5 # Chop out NDATA decl
|
|
381
|
+
# match is [ :entity, name, PUBLIC, pubid, href(, ndata)? ]
|
|
382
|
+
when Private::PEREFERENCE_PATTERN
|
|
383
|
+
raise REXML::ParseException.new(
|
|
384
|
+
"Parameter entity references forbidden in internal subset: #{match[2]}", @source
|
|
385
|
+
)
|
|
386
|
+
else
|
|
387
|
+
match[2] = match[2][1..-2]
|
|
388
|
+
match.pop if match.size == 4
|
|
389
|
+
# match is [ :entity, name, value ]
|
|
390
|
+
end
|
|
391
|
+
match << "%" if ref
|
|
392
|
+
return match
|
|
393
|
+
elsif @source.match?("ATTLIST", true)
|
|
394
|
+
md = @source.match(Private::ATTLISTDECL_END, true)
|
|
395
|
+
if md.nil?
|
|
396
|
+
raise REXML::ParseException.new("Bad ATTLIST declaration!",
|
|
397
|
+
@source)
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
element = md[1]
|
|
401
|
+
contents = "<!ATTLIST#{md[0]}"
|
|
402
|
+
|
|
403
|
+
pairs = {}
|
|
404
|
+
values = md[0].strip.scan(ATTDEF_RE)
|
|
405
|
+
values.each do |attdef|
|
|
406
|
+
unless attdef[3] == "#IMPLIED"
|
|
407
|
+
attdef.compact!
|
|
408
|
+
val = attdef[3]
|
|
409
|
+
val = attdef[4] if val == "#FIXED "
|
|
410
|
+
pairs[attdef[0]] = val
|
|
411
|
+
if attdef[0] =~ /^xmlns:(.*)/
|
|
412
|
+
@namespaces[$1] = val
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
return [:attlistdecl, element, pairs, contents]
|
|
417
|
+
elsif @source.match?("NOTATION", true)
|
|
418
|
+
base_error_message = "Malformed notation declaration"
|
|
419
|
+
unless @source.skip_spaces
|
|
420
|
+
message = if @source.match?(">")
|
|
421
|
+
"#{base_error_message}: name is missing"
|
|
422
|
+
else
|
|
423
|
+
"#{base_error_message}: invalid name"
|
|
424
|
+
end
|
|
425
|
+
@source.position = start_position
|
|
426
|
+
raise REXML::ParseException.new(message, @source)
|
|
427
|
+
end
|
|
428
|
+
name = parse_name(base_error_message)
|
|
429
|
+
id = parse_id(base_error_message,
|
|
430
|
+
accept_external_id: true,
|
|
431
|
+
accept_public_id: true)
|
|
432
|
+
@source.skip_spaces
|
|
433
|
+
unless @source.match?(">", true)
|
|
434
|
+
message = "#{base_error_message}: garbage before end >"
|
|
435
|
+
raise REXML::ParseException.new(message, @source)
|
|
436
|
+
end
|
|
437
|
+
return [:notationdecl, name, *id]
|
|
438
|
+
elsif @source.match?("--", true)
|
|
439
|
+
return [:comment, process_comment]
|
|
440
|
+
else
|
|
441
|
+
raise REXML::ParseException.new(
|
|
442
|
+
"Malformed node: Started with '<!' but not a comment nor ELEMENT,ENTITY,ATTLIST,NOTATION", @source
|
|
443
|
+
)
|
|
444
|
+
end
|
|
445
|
+
elsif match = @source.match(/(%.*?;)\s*/um, true)
|
|
446
|
+
return [:externalentity, match[1]]
|
|
447
|
+
elsif @source.match?(/\]\s*>/um, true)
|
|
448
|
+
@document_status = :after_doctype
|
|
449
|
+
return [:end_doctype]
|
|
450
|
+
else
|
|
451
|
+
raise ParseException.new("Malformed DOCTYPE: invalid declaration",
|
|
452
|
+
@source)
|
|
453
|
+
end
|
|
454
|
+
end
|
|
455
|
+
if @document_status == :after_doctype
|
|
456
|
+
@source.skip_spaces
|
|
457
|
+
end
|
|
458
|
+
begin
|
|
459
|
+
start_position = @source.position
|
|
460
|
+
if @source.match?("<", true)
|
|
461
|
+
# :text's read_until may remain only "<" in buffer. In the
|
|
462
|
+
# case, buffer is empty here. So we need to fill buffer
|
|
463
|
+
# here explicitly.
|
|
464
|
+
@source.ensure_buffer
|
|
465
|
+
if @source.match?("/", true)
|
|
466
|
+
@namespaces_restore_stack.pop
|
|
467
|
+
last_tag = @tags.pop
|
|
468
|
+
md = @source.match(Private::CLOSE_PATTERN, true)
|
|
469
|
+
if md && !last_tag
|
|
470
|
+
message = "Unexpected top-level end tag (got '#{md[1]}')"
|
|
471
|
+
raise REXML::ParseException.new(message, @source)
|
|
472
|
+
end
|
|
473
|
+
if md.nil? || (last_tag != md[1])
|
|
474
|
+
message = "Missing end tag for '#{last_tag}'"
|
|
475
|
+
message += " (got '#{md[1]}')" if md
|
|
476
|
+
@source.position = start_position if md.nil?
|
|
477
|
+
raise REXML::ParseException.new(message, @source)
|
|
478
|
+
end
|
|
479
|
+
[:end_element, last_tag]
|
|
480
|
+
elsif @source.match?("!", true)
|
|
481
|
+
# STDERR.puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}"
|
|
482
|
+
if @source.match?("--", true)
|
|
483
|
+
[:comment, process_comment]
|
|
484
|
+
elsif @source.match?("[CDATA[", true)
|
|
485
|
+
text = @source.read_until("]]>")
|
|
486
|
+
unless text.end_with?("]]>")
|
|
487
|
+
raise REXML::ParseException.new(
|
|
488
|
+
"Malformed CDATA: Missing end ']]>'", @source
|
|
489
|
+
)
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
text = text[0...-3]
|
|
493
|
+
[:cdata, text]
|
|
494
|
+
else
|
|
495
|
+
raise REXML::ParseException.new(
|
|
496
|
+
"Malformed node: Started with '<!' but not a comment nor CDATA", @source
|
|
497
|
+
)
|
|
498
|
+
end
|
|
499
|
+
elsif @source.match?("?", true)
|
|
500
|
+
process_instruction
|
|
501
|
+
else
|
|
502
|
+
# Get the next tag
|
|
503
|
+
md = @source.match(Private::TAG_PATTERN, true)
|
|
504
|
+
unless md
|
|
505
|
+
@source.position = start_position
|
|
506
|
+
raise REXML::ParseException.new(
|
|
507
|
+
"malformed XML: missing tag start", @source
|
|
508
|
+
)
|
|
509
|
+
end
|
|
510
|
+
tag = md[1]
|
|
511
|
+
@document_status = :in_element
|
|
512
|
+
@prefixes.clear
|
|
513
|
+
@prefixes << md[2] if md[2]
|
|
514
|
+
push_namespaces_restore
|
|
515
|
+
attributes, closed = parse_attributes(@prefixes)
|
|
516
|
+
# Verify that all of the prefixes have been defined
|
|
517
|
+
@prefixes.each do |prefix|
|
|
518
|
+
unless @namespaces.key?(prefix)
|
|
519
|
+
raise UndefinedNamespaceException.new(prefix, @source, self)
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
if closed
|
|
524
|
+
@closed = tag
|
|
525
|
+
pop_namespaces_restore
|
|
526
|
+
else
|
|
527
|
+
if @tags.empty? && @have_root
|
|
528
|
+
raise ParseException.new(
|
|
529
|
+
"Malformed XML: Extra tag at the end of the document (got '<#{tag}')", @source
|
|
530
|
+
)
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
@tags.push(tag)
|
|
534
|
+
end
|
|
535
|
+
@have_root = true
|
|
536
|
+
[:start_element, tag, attributes]
|
|
537
|
+
end
|
|
538
|
+
else
|
|
539
|
+
text = @source.read_until("<")
|
|
540
|
+
if text.end_with?("<")
|
|
541
|
+
text = text[0...-1]
|
|
542
|
+
@source.position -= "<".bytesize
|
|
543
|
+
end
|
|
544
|
+
if @tags.empty?
|
|
545
|
+
unless /^\s*$/.match?(text)
|
|
546
|
+
if @have_root
|
|
547
|
+
raise ParseException.new(
|
|
548
|
+
"Malformed XML: Extra content at the end of the document (got '#{text}')", @source
|
|
549
|
+
)
|
|
550
|
+
else
|
|
551
|
+
raise ParseException.new(
|
|
552
|
+
"Malformed XML: Content at the start of the document (got '#{text}')", @source
|
|
553
|
+
)
|
|
554
|
+
end
|
|
555
|
+
end
|
|
556
|
+
return pull_event if @have_root
|
|
557
|
+
end
|
|
558
|
+
[:text, text]
|
|
559
|
+
end
|
|
560
|
+
rescue REXML::UndefinedNamespaceException
|
|
561
|
+
raise
|
|
562
|
+
rescue REXML::ParseException
|
|
563
|
+
raise
|
|
564
|
+
rescue StandardError => e
|
|
565
|
+
raise REXML::ParseException.new("Exception parsing",
|
|
566
|
+
@source, self, e || $!)
|
|
567
|
+
end
|
|
568
|
+
# NOTE: The end of the method never runs, because it is unreachable.
|
|
569
|
+
# All branches of code above have explicit unconditional return or raise statements.
|
|
570
|
+
end
|
|
571
|
+
private :pull_event
|
|
572
|
+
|
|
573
|
+
def entity(reference, entities)
|
|
574
|
+
return unless entities
|
|
575
|
+
|
|
576
|
+
value = entities[reference]
|
|
577
|
+
return if value.nil?
|
|
578
|
+
|
|
579
|
+
record_entity_expansion
|
|
580
|
+
unnormalize(value, entities)
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
# Escapes all possible entities
|
|
584
|
+
def normalize(input, entities = nil, entity_filter = nil)
|
|
585
|
+
copy = input.clone
|
|
586
|
+
# Doing it like this rather than in a loop improves the speed
|
|
587
|
+
copy.gsub!(EREFERENCE, "&")
|
|
588
|
+
if entities
|
|
589
|
+
entities.each do |key, value|
|
|
590
|
+
unless entity_filter && entity_filter.include?(entity)
|
|
591
|
+
copy.gsub!(value, "&#{key};")
|
|
592
|
+
end
|
|
593
|
+
end
|
|
594
|
+
end
|
|
595
|
+
copy.gsub!(EREFERENCE, "&")
|
|
596
|
+
DEFAULT_ENTITIES.each_value do |value|
|
|
597
|
+
copy.gsub!(value[3], value[1])
|
|
598
|
+
end
|
|
599
|
+
copy
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
# Unescapes all possible entities
|
|
603
|
+
def unnormalize(string, entities = nil, filter = nil)
|
|
604
|
+
rv = if string.include?("\r")
|
|
605
|
+
string.gsub(Private::CARRIAGE_RETURN_NEWLINE_PATTERN, "\n")
|
|
606
|
+
else
|
|
607
|
+
string.dup
|
|
608
|
+
end
|
|
609
|
+
matches = rv.scan(REFERENCE_RE)
|
|
610
|
+
return rv if matches.empty?
|
|
611
|
+
|
|
612
|
+
rv.gsub!(Private::CHARACTER_REFERENCES) do
|
|
613
|
+
m = $1
|
|
614
|
+
code_point = if m.start_with?("x")
|
|
615
|
+
Integer(m[1..], 16)
|
|
616
|
+
else
|
|
617
|
+
Integer(m, 10)
|
|
618
|
+
end
|
|
619
|
+
[code_point].pack("U*")
|
|
620
|
+
end
|
|
621
|
+
matches.collect! { |x| x[0] }.compact!
|
|
622
|
+
if filter
|
|
623
|
+
matches.reject! do |entity_reference|
|
|
624
|
+
filter.include?(entity_reference)
|
|
625
|
+
end
|
|
626
|
+
end
|
|
627
|
+
if matches.size.positive?
|
|
628
|
+
matches.tally.each do |entity_reference, n|
|
|
629
|
+
entity_expansion_count_before = @entity_expansion_count
|
|
630
|
+
entity_value = entity(entity_reference, entities)
|
|
631
|
+
if entity_value
|
|
632
|
+
if n > 1
|
|
633
|
+
entity_expansion_count_delta =
|
|
634
|
+
@entity_expansion_count - entity_expansion_count_before
|
|
635
|
+
record_entity_expansion(entity_expansion_count_delta * (n - 1))
|
|
636
|
+
end
|
|
637
|
+
re = Private::DEFAULT_ENTITIES_PATTERNS[entity_reference] || /&#{entity_reference};/
|
|
638
|
+
rv.gsub!(re, entity_value)
|
|
639
|
+
if rv.bytesize > @entity_expansion_text_limit
|
|
640
|
+
raise "entity expansion has grown too large"
|
|
641
|
+
end
|
|
642
|
+
else
|
|
643
|
+
er = DEFAULT_ENTITIES[entity_reference]
|
|
644
|
+
rv.gsub!(er[0], er[2]) if er
|
|
645
|
+
end
|
|
646
|
+
end
|
|
647
|
+
rv.gsub!(Private::DEFAULT_ENTITIES_PATTERNS["amp"], "&")
|
|
648
|
+
end
|
|
649
|
+
rv
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
private
|
|
653
|
+
|
|
654
|
+
def add_namespace(prefix, uri)
|
|
655
|
+
@namespaces_restore_stack.last[prefix] = @namespaces[prefix]
|
|
656
|
+
if uri.nil?
|
|
657
|
+
@namespaces.delete(prefix)
|
|
658
|
+
else
|
|
659
|
+
@namespaces[prefix] = uri
|
|
660
|
+
end
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
def push_namespaces_restore
|
|
664
|
+
namespaces_restore = {}
|
|
665
|
+
@namespaces_restore_stack.push(namespaces_restore)
|
|
666
|
+
namespaces_restore
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
def pop_namespaces_restore
|
|
670
|
+
namespaces_restore = @namespaces_restore_stack.pop
|
|
671
|
+
namespaces_restore.each do |prefix, uri|
|
|
672
|
+
if uri.nil?
|
|
673
|
+
@namespaces.delete(prefix)
|
|
674
|
+
else
|
|
675
|
+
@namespaces[prefix] = uri
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
end
|
|
679
|
+
|
|
680
|
+
def record_entity_expansion(delta = 1)
|
|
681
|
+
@entity_expansion_count += delta
|
|
682
|
+
if @entity_expansion_count > @entity_expansion_limit
|
|
683
|
+
raise "number of entity expansions exceeded, processing aborted."
|
|
684
|
+
end
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
def need_source_encoding_update?(xml_declaration_encoding)
|
|
688
|
+
return false if xml_declaration_encoding.nil?
|
|
689
|
+
return false if /^UTF-16$/i.match?(xml_declaration_encoding)
|
|
690
|
+
|
|
691
|
+
true
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
def normalize_xml_declaration_encoding(xml_declaration_encoding)
|
|
695
|
+
/^UTF-16(?:BE|LE)$/i.match?(xml_declaration_encoding) ? "UTF-16" : nil
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
def parse_name(base_error_message)
|
|
699
|
+
md = @source.match(Private::NAME_PATTERN, true)
|
|
700
|
+
unless md
|
|
701
|
+
message = if @source.match?(/\S/um)
|
|
702
|
+
"#{base_error_message}: invalid name"
|
|
703
|
+
else
|
|
704
|
+
"#{base_error_message}: name is missing"
|
|
705
|
+
end
|
|
706
|
+
raise REXML::ParseException.new(message, @source)
|
|
707
|
+
end
|
|
708
|
+
md[0]
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
def parse_id(base_error_message,
|
|
712
|
+
accept_external_id:,
|
|
713
|
+
accept_public_id:)
|
|
714
|
+
if accept_external_id && (md = @source.match(EXTERNAL_ID_PUBLIC, true))
|
|
715
|
+
pubid = system = nil
|
|
716
|
+
pubid_literal = md[1]
|
|
717
|
+
pubid = pubid_literal[1..-2] if pubid_literal # Remove quote
|
|
718
|
+
system_literal = md[2]
|
|
719
|
+
system = system_literal[1..-2] if system_literal # Remove quote
|
|
720
|
+
["PUBLIC", pubid, system]
|
|
721
|
+
elsif accept_public_id && (md = @source.match(PUBLIC_ID, true))
|
|
722
|
+
pubid = nil
|
|
723
|
+
pubid_literal = md[1]
|
|
724
|
+
pubid = pubid_literal[1..-2] if pubid_literal # Remove quote
|
|
725
|
+
["PUBLIC", pubid, nil]
|
|
726
|
+
elsif accept_external_id && (md = @source.match(EXTERNAL_ID_SYSTEM,
|
|
727
|
+
true))
|
|
728
|
+
system = nil
|
|
729
|
+
system_literal = md[1]
|
|
730
|
+
system = system_literal[1..-2] if system_literal # Remove quote
|
|
731
|
+
["SYSTEM", nil, system]
|
|
732
|
+
else
|
|
733
|
+
details = parse_id_invalid_details(accept_external_id: accept_external_id,
|
|
734
|
+
accept_public_id: accept_public_id)
|
|
735
|
+
message = "#{base_error_message}: #{details}"
|
|
736
|
+
raise REXML::ParseException.new(message, @source)
|
|
737
|
+
end
|
|
738
|
+
end
|
|
739
|
+
|
|
740
|
+
def parse_id_invalid_details(accept_external_id:,
|
|
741
|
+
accept_public_id:)
|
|
742
|
+
public = /^\s*PUBLIC/um
|
|
743
|
+
system = /^\s*SYSTEM/um
|
|
744
|
+
if (accept_external_id || accept_public_id) && @source.match?(/#{public}/um)
|
|
745
|
+
if @source.match?(/#{public}(?:\s+[^'"]|\s*[\[>])/um)
|
|
746
|
+
return "public ID literal is missing"
|
|
747
|
+
end
|
|
748
|
+
unless @source.match?(/#{public}\s+#{PUBIDLITERAL}/um)
|
|
749
|
+
return "invalid public ID literal"
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
if accept_public_id
|
|
753
|
+
if @source.match?(/#{public}\s+#{PUBIDLITERAL}\s+[^'"]/um)
|
|
754
|
+
return "system ID literal is missing"
|
|
755
|
+
end
|
|
756
|
+
unless @source.match?(/#{public}\s+#{PUBIDLITERAL}\s+#{SYSTEMLITERAL}/um)
|
|
757
|
+
return "invalid system literal"
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
"garbage after system literal"
|
|
761
|
+
else
|
|
762
|
+
"garbage after public ID literal"
|
|
763
|
+
end
|
|
764
|
+
elsif accept_external_id && @source.match?(/#{system}/um)
|
|
765
|
+
if @source.match?(/#{system}(?:\s+[^'"]|\s*[\[>])/um)
|
|
766
|
+
return "system literal is missing"
|
|
767
|
+
end
|
|
768
|
+
unless @source.match?(/#{system}\s+#{SYSTEMLITERAL}/um)
|
|
769
|
+
return "invalid system literal"
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
"garbage after system literal"
|
|
773
|
+
else
|
|
774
|
+
unless @source.match?(/^\s*(?:PUBLIC|SYSTEM)\s/um)
|
|
775
|
+
return "invalid ID type"
|
|
776
|
+
end
|
|
777
|
+
|
|
778
|
+
"ID type is missing"
|
|
779
|
+
end
|
|
780
|
+
end
|
|
781
|
+
|
|
782
|
+
def process_comment
|
|
783
|
+
text = @source.read_until("-->")
|
|
784
|
+
unless text.end_with?("-->")
|
|
785
|
+
raise REXML::ParseException.new(
|
|
786
|
+
"Unclosed comment: Missing end '-->'", @source
|
|
787
|
+
)
|
|
788
|
+
end
|
|
789
|
+
|
|
790
|
+
text = text[0...-3]
|
|
791
|
+
|
|
792
|
+
if text.include?("--") || text.end_with?("-")
|
|
793
|
+
raise REXML::ParseException.new("Malformed comment", @source)
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
text
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
def process_instruction
|
|
800
|
+
name = parse_name("Malformed XML: Invalid processing instruction node")
|
|
801
|
+
if name == "xml"
|
|
802
|
+
xml_declaration
|
|
803
|
+
else # PITarget
|
|
804
|
+
if @source.skip_spaces # e.g. <?name content?>
|
|
805
|
+
start_position = @source.position
|
|
806
|
+
content = @source.read_until("?>")
|
|
807
|
+
unless content.end_with?("?>")
|
|
808
|
+
@source.position = start_position
|
|
809
|
+
raise ParseException.new(
|
|
810
|
+
"Malformed XML: Unclosed processing instruction: <#{name}>", @source
|
|
811
|
+
)
|
|
812
|
+
end
|
|
813
|
+
content = content[0...-2]
|
|
814
|
+
else # e.g. <?name?>
|
|
815
|
+
content = nil
|
|
816
|
+
unless @source.match?("?>", true)
|
|
817
|
+
raise ParseException.new(
|
|
818
|
+
"Malformed XML: Unclosed processing instruction: <#{name}>", @source
|
|
819
|
+
)
|
|
820
|
+
end
|
|
821
|
+
end
|
|
822
|
+
[:processing_instruction, name, content]
|
|
823
|
+
end
|
|
824
|
+
end
|
|
825
|
+
|
|
826
|
+
def xml_declaration
|
|
827
|
+
unless @version.nil?
|
|
828
|
+
raise ParseException.new(
|
|
829
|
+
"Malformed XML: XML declaration is duplicated", @source
|
|
830
|
+
)
|
|
831
|
+
end
|
|
832
|
+
if @document_status
|
|
833
|
+
raise ParseException.new(
|
|
834
|
+
"Malformed XML: XML declaration is not at the start", @source
|
|
835
|
+
)
|
|
836
|
+
end
|
|
837
|
+
unless @source.skip_spaces
|
|
838
|
+
raise ParseException.new(
|
|
839
|
+
"Malformed XML: XML declaration misses spaces before version", @source
|
|
840
|
+
)
|
|
841
|
+
end
|
|
842
|
+
unless @source.match?("version", true)
|
|
843
|
+
raise ParseException.new(
|
|
844
|
+
"Malformed XML: XML declaration misses version", @source
|
|
845
|
+
)
|
|
846
|
+
end
|
|
847
|
+
|
|
848
|
+
@version = parse_attribute_value_with_equal("xml")
|
|
849
|
+
unless @source.skip_spaces
|
|
850
|
+
unless @source.match?("?>", true)
|
|
851
|
+
raise ParseException.new("Malformed XML: Unclosed XML declaration",
|
|
852
|
+
@source)
|
|
853
|
+
end
|
|
854
|
+
|
|
855
|
+
encoding = normalize_xml_declaration_encoding(@source.encoding)
|
|
856
|
+
return [:xmldecl, @version, encoding, nil] # e.g. <?xml version="1.0"?>
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
if @source.match?("encoding", true)
|
|
860
|
+
encoding = parse_attribute_value_with_equal("xml")
|
|
861
|
+
unless @source.skip_spaces
|
|
862
|
+
unless @source.match?("?>", true)
|
|
863
|
+
raise ParseException.new(
|
|
864
|
+
"Malformed XML: Unclosed XML declaration", @source
|
|
865
|
+
)
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
if need_source_encoding_update?(encoding)
|
|
869
|
+
@source.encoding = encoding
|
|
870
|
+
end
|
|
871
|
+
encoding ||= normalize_xml_declaration_encoding(@source.encoding)
|
|
872
|
+
return [:xmldecl, @version, encoding, nil] # e.g. <?xml version="1.1" encoding="UTF-8"?>
|
|
873
|
+
end
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
if @source.match?("standalone", true)
|
|
877
|
+
standalone = parse_attribute_value_with_equal("xml")
|
|
878
|
+
case standalone
|
|
879
|
+
when "yes", "no"
|
|
880
|
+
else
|
|
881
|
+
raise ParseException.new(
|
|
882
|
+
"Malformed XML: XML declaration standalone is not yes or no : <#{standalone}>", @source
|
|
883
|
+
)
|
|
884
|
+
end
|
|
885
|
+
end
|
|
886
|
+
@source.skip_spaces
|
|
887
|
+
unless @source.match?("?>", true)
|
|
888
|
+
raise ParseException.new("Malformed XML: Unclosed XML declaration",
|
|
889
|
+
@source)
|
|
890
|
+
end
|
|
891
|
+
|
|
892
|
+
if need_source_encoding_update?(encoding)
|
|
893
|
+
@source.encoding = encoding
|
|
894
|
+
end
|
|
895
|
+
encoding ||= normalize_xml_declaration_encoding(@source.encoding)
|
|
896
|
+
|
|
897
|
+
# e.g. <?xml version="1.0" ?>
|
|
898
|
+
# <?xml version="1.1" encoding="UTF-8" ?>
|
|
899
|
+
# <?xml version="1.1" standalone="yes"?>
|
|
900
|
+
# <?xml version="1.1" encoding="UTF-8" standalone="yes" ?>
|
|
901
|
+
[:xmldecl, @version, encoding, standalone]
|
|
902
|
+
end
|
|
903
|
+
|
|
904
|
+
if StringScanner::Version < "3.1.1"
|
|
905
|
+
def scan_quote
|
|
906
|
+
@source.match(/(['"])/, true)&.[](1)
|
|
907
|
+
end
|
|
908
|
+
else
|
|
909
|
+
def scan_quote
|
|
910
|
+
case @source.peek_byte
|
|
911
|
+
when 34 # '"'.ord
|
|
912
|
+
@source.scan_byte
|
|
913
|
+
'"'
|
|
914
|
+
when 39 # "'".ord
|
|
915
|
+
@source.scan_byte
|
|
916
|
+
"'"
|
|
917
|
+
end
|
|
918
|
+
end
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
def parse_attribute_value_with_equal(name)
|
|
922
|
+
unless @source.match?(Private::EQUAL_PATTERN, true)
|
|
923
|
+
message = "Missing attribute equal: <#{name}>"
|
|
924
|
+
raise REXML::ParseException.new(message, @source)
|
|
925
|
+
end
|
|
926
|
+
unless quote = scan_quote
|
|
927
|
+
message = "Missing attribute value start quote: <#{name}>"
|
|
928
|
+
raise REXML::ParseException.new(message, @source)
|
|
929
|
+
end
|
|
930
|
+
start_position = @source.position
|
|
931
|
+
value = @source.read_until(quote)
|
|
932
|
+
unless value.end_with?(quote)
|
|
933
|
+
@source.position = start_position
|
|
934
|
+
message = "Missing attribute value end quote: <#{name}>: <#{quote}>"
|
|
935
|
+
raise REXML::ParseException.new(message, @source)
|
|
936
|
+
end
|
|
937
|
+
value[0...-1]
|
|
938
|
+
end
|
|
939
|
+
|
|
940
|
+
def parse_attributes(prefixes)
|
|
941
|
+
attributes = {}
|
|
942
|
+
expanded_names = {}
|
|
943
|
+
closed = false
|
|
944
|
+
loop do
|
|
945
|
+
if @source.match?(">", true)
|
|
946
|
+
return attributes, closed
|
|
947
|
+
elsif @source.match?("/>", true)
|
|
948
|
+
closed = true
|
|
949
|
+
return attributes, closed
|
|
950
|
+
elsif match = @source.match(QNAME, true)
|
|
951
|
+
name = match[1]
|
|
952
|
+
prefix = match[2]
|
|
953
|
+
local_part = match[3]
|
|
954
|
+
value = parse_attribute_value_with_equal(name)
|
|
955
|
+
@source.skip_spaces
|
|
956
|
+
if prefix == "xmlns"
|
|
957
|
+
if local_part == "xml"
|
|
958
|
+
if value != Private::XML_PREFIXED_NAMESPACE
|
|
959
|
+
msg = "The 'xml' prefix must not be bound to any other namespace " +
|
|
960
|
+
"(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
|
|
961
|
+
raise REXML::ParseException.new(msg, @source, self)
|
|
962
|
+
end
|
|
963
|
+
elsif local_part == "xmlns"
|
|
964
|
+
msg = "The 'xmlns' prefix must not be declared " +
|
|
965
|
+
"(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
|
|
966
|
+
raise REXML::ParseException.new(msg, @source, self)
|
|
967
|
+
end
|
|
968
|
+
add_namespace(local_part, value)
|
|
969
|
+
elsif prefix
|
|
970
|
+
prefixes << prefix unless prefix == "xml"
|
|
971
|
+
end
|
|
972
|
+
|
|
973
|
+
if attributes[name]
|
|
974
|
+
msg = "Duplicate attribute #{name.inspect}"
|
|
975
|
+
raise REXML::ParseException.new(msg, @source, self)
|
|
976
|
+
end
|
|
977
|
+
|
|
978
|
+
unless prefix == "xmlns"
|
|
979
|
+
uri = @namespaces[prefix]
|
|
980
|
+
expanded_name = [uri, local_part]
|
|
981
|
+
existing_prefix = expanded_names[expanded_name]
|
|
982
|
+
if existing_prefix
|
|
983
|
+
message = "Namespace conflict in adding attribute \"#{local_part}\": Prefix \"#{existing_prefix}\" = \"#{uri}\" and prefix \"#{prefix}\" = \"#{uri}\""
|
|
984
|
+
raise REXML::ParseException.new(message, @source, self)
|
|
985
|
+
end
|
|
986
|
+
expanded_names[expanded_name] = prefix
|
|
987
|
+
end
|
|
988
|
+
|
|
989
|
+
attributes[name] = value
|
|
990
|
+
else
|
|
991
|
+
message = "Invalid attribute name: <#{@source.buffer.split(%r{[/>\s]}).first}>"
|
|
992
|
+
raise REXML::ParseException.new(message, @source)
|
|
993
|
+
end
|
|
994
|
+
end
|
|
995
|
+
end
|
|
996
|
+
end
|
|
997
|
+
end
|
|
998
|
+
end
|
|
999
|
+
|
|
1000
|
+
# case event[0]
|
|
1001
|
+
# when :start_element
|
|
1002
|
+
# when :text
|
|
1003
|
+
# when :end_element
|
|
1004
|
+
# when :processing_instruction
|
|
1005
|
+
# when :cdata
|
|
1006
|
+
# when :comment
|
|
1007
|
+
# when :xmldecl
|
|
1008
|
+
# when :start_doctype
|
|
1009
|
+
# when :end_doctype
|
|
1010
|
+
# when :externalentity
|
|
1011
|
+
# when :elementdecl
|
|
1012
|
+
# when :entity
|
|
1013
|
+
# when :attlistdecl
|
|
1014
|
+
# when :notationdecl
|
|
1015
|
+
# when :end_doctype
|
|
1016
|
+
# end
|