Class: XSD::Include
- Inherits:
-
BaseObject
- Object
- BaseObject
- XSD::Include
- 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 https://www.w3schools.com/xml/el_include.asp
Constant Summary
Constants inherited from BaseObject
BaseObject::NO_ATTRIBUTES_CONTAINER, BaseObject::NO_ELEMENTS_CONTAINER, BaseObject::XML_SCHEMA, BaseObject::XML_SCHEMA_NS
Instance Attribute Summary collapse
-
#schema_location ⇒ Object
Required.
Attributes inherited from BaseObject
Instance Method Summary collapse
-
#imported_schema ⇒ Object
Get included schema.
Methods inherited from BaseObject
#[], child, #collect_attributes, #collect_elements, #documentation, #documentation_for, #get_prefix, #initialize, #inspect, link, #map_child, #map_children, mapped_name, #namespaces, #node, #node_to_object, #nodes, #object_by_name, #parent, property, #reader, #schema, #schemas_for_namespace, #strip_prefix, to_underscore
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_location ⇒ Object
Required. Specifies the URI to the schema to include in the target namespace of the containing schema
11 |
# File 'lib/xsd/objects/include.rb', line 11 property :schemaLocation, :string |
Instance Method Details
#imported_schema ⇒ Object
Get included 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 raise ImportError, 'Schema location not provided for include' unless schema_location new_schema = reader.load_schema(schema_location, base: schema.location) # an included schema without a target namespace adopts the namespace of the including schema ("chameleon" include) unless new_schema.target_namespace.nil? || schema.target_namespace == new_schema.target_namespace raise ImportError, "Schema targetNamespace '#{schema.target_namespace}' does not match included schema " \ "targetNamespace '#{new_schema.target_namespace}'" end new_schema end |