Class: Lutaml::Xml::SchemaLocation
- Inherits:
-
Object
- Object
- Lutaml::Xml::SchemaLocation
- Defined in:
- lib/lutaml/xml/schema_location.rb
Overview
SchemaLocation manages xsi:schemaLocation attribute which provides schema validation hints as namespace-location pairs
Uses W3C XmlSchema-instance namespace (xsi) for the schemaLocation attribute itself. Each location pair associates a namespace (via XmlNamespace class) with its schema URL.
Instance Attribute Summary collapse
-
#schema_location ⇒ Object
readonly
Returns the value of attribute schema_location.
-
#xsi_prefix ⇒ Object
readonly
Returns the value of attribute xsi_prefix.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(locations:, xsi_prefix: "xsi") ⇒ SchemaLocation
constructor
A new instance of SchemaLocation.
- #size ⇒ Object
-
#to_xml_attributes ⇒ Hash{String => String}
Generate XML attributes for schema location declaration.
-
#xsi_namespace ⇒ String
Returns the XMLSchema-instance namespace URI.
-
#xsi_namespace_class ⇒ Class
Returns the XMLSchema-instance namespace class.
Constructor Details
#initialize(locations:, xsi_prefix: "xsi") ⇒ SchemaLocation
Returns a new instance of SchemaLocation.
84 85 86 87 |
# File 'lib/lutaml/xml/schema_location.rb', line 84 def initialize(locations:, xsi_prefix: "xsi") @schema_location = build_locations(locations) @xsi_prefix = xsi_prefix end |
Instance Attribute Details
#schema_location ⇒ Object (readonly)
Returns the value of attribute schema_location.
80 81 82 |
# File 'lib/lutaml/xml/schema_location.rb', line 80 def schema_location @schema_location end |
#xsi_prefix ⇒ Object (readonly)
Returns the value of attribute xsi_prefix.
80 81 82 |
# File 'lib/lutaml/xml/schema_location.rb', line 80 def xsi_prefix @xsi_prefix end |
Instance Method Details
#[](index) ⇒ Object
110 111 112 |
# File 'lib/lutaml/xml/schema_location.rb', line 110 def [](index) @schema_location[index] end |
#size ⇒ Object
114 115 116 |
# File 'lib/lutaml/xml/schema_location.rb', line 114 def size @schema_location.size end |
#to_xml_attributes ⇒ Hash{String => String}
Generate XML attributes for schema location declaration
103 104 105 106 107 108 |
# File 'lib/lutaml/xml/schema_location.rb', line 103 def to_xml_attributes { "xmlns:#{xsi_prefix}" => xsi_namespace, "#{xsi_prefix}:schemaLocation" => schema_location.map(&:to_xml_attribute).join(" "), } end |
#xsi_namespace ⇒ String
Returns the XMLSchema-instance namespace URI
97 98 99 |
# File 'lib/lutaml/xml/schema_location.rb', line 97 def xsi_namespace xsi_namespace_class.uri end |
#xsi_namespace_class ⇒ Class
Returns the XMLSchema-instance namespace class
91 92 93 |
# File 'lib/lutaml/xml/schema_location.rb', line 91 def xsi_namespace_class Lutaml::Xml::W3c::XsiNamespace end |