Class: XSD::Include

Inherits:
BaseObject show all
Defined in:
lib/xsd/objects/include.rb

Overview

The include element is used to add multiple schemas with the same target namespace to a document. Parent elements: schema www.w3schools.com/xml/el_include.asp

Constant Summary

Constants inherited from BaseObject

BaseObject::NO_ATTRIBUTES_CONTAINER, BaseObject::NO_ELEMENTS_CONTAINER, BaseObject::XML_SCHEMA

Instance Attribute Summary collapse

Attributes inherited from BaseObject

#id, #options

Instance Method Summary collapse

Methods inherited from BaseObject

#[], #collect_attributes, #collect_elements, #documentation, #documentation_for, #get_prefix, #initialize, #inspect, #map_child, #map_children, #namespaces, #node, #node_to_object, #nodes, #object_by_name, #parent, #reader, #schema, #schemas_for_namespace, #strip_prefix

Constructor Details

This class inherits a constructor from XSD::BaseObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class XSD::BaseObject

Instance Attribute Details

#schema_locationObject

Required. Specifies the URI to the schema to include in the target namespace of the containing schema

Returns:

  • String



11
# File 'lib/xsd/objects/include.rb', line 11

property :schemaLocation, :string

Instance Method Details

#imported_schemaObject

Get imported schema

Returns:

  • Schema



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xsd/objects/include.rb', line 15

def imported_schema
  # cache included schema locally as it has no unique namespace to check in global registry
  return @imported_schema if @imported_schema

  xml = reader.resource_resolver.call(schema_location)
  new_schema = reader.add_schema_xml(xml)

  unless schema.target_namespace == new_schema.target_namespace
    raise ImportError, 'Schema targetNamespace does not match included schema targetNamespace'
  end

  @imported_schema = new_schema
end