Class: WSDL::Schema::Definition
- Inherits:
-
Object
- Object
- WSDL::Schema::Definition
- Includes:
- Log
- Defined in:
- lib/wsdl/schema/definition.rb
Overview
Represents a parsed XML Schema (XSD) document.
Parses an xs:schema element and provides access to its components: elements, complex types, simple types, attributes, and attribute groups. Also tracks schema imports and includes for resolving cross-schema refs.
Instance Attribute Summary collapse
-
#attribute_groups ⇒ Hash{String => Node}
readonly
Attribute group definitions.
-
#attributes ⇒ Hash{String => Node}
readonly
Global attribute declarations.
-
#complex_types ⇒ Hash{String => Node}
readonly
Complex type definitions.
-
#element_form_default ⇒ String
readonly
'qualified' or 'unqualified'.
-
#elements ⇒ Hash{String => Node}
readonly
Global element declarations.
-
#groups ⇒ Hash{String => Node}
readonly
Model group definitions.
-
#import_locations ⇒ Array<String>
readonly
All import schemaLocation values (supports multiple per namespace).
-
#imports ⇒ Hash{String => String}
readonly
Namespace to schemaLocation mappings.
-
#includes ⇒ Array<String>
readonly
SchemaLocation values for includes.
-
#simple_types ⇒ Hash{String => Node}
readonly
Simple type definitions.
-
#source_location ⇒ String?
readonly
The location this schema was loaded from.
-
#target_namespace ⇒ String?
readonly
The target namespace URI.
Instance Method Summary collapse
-
#initialize(schema_node, collection, source_location = nil) ⇒ Definition
constructor
Creates a new Definition by parsing an XML Schema node.
-
#merge(other) ⇒ void
Merges another definition's contents into this one.
-
#release_dom_references! ⇒ void
Releases all references to the Nokogiri DOM from this definition and every Node it contains.
Methods included from Log
Constructor Details
#initialize(schema_node, collection, source_location = nil) ⇒ Definition
Creates a new Definition by parsing an XML Schema node.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wsdl/schema/definition.rb', line 24 def initialize(schema_node, collection, source_location = nil) @schema_node = schema_node @collection = collection @source_location = source_location @target_namespace = schema_node['targetNamespace'] @element_form_default = schema_node['elementFormDefault'] || 'unqualified' @elements = {} @complex_types = {} @simple_types = {} @attributes = {} @attribute_groups = {} @groups = {} @imports = {} @import_locations = [] @includes = [] parse end |
Instance Attribute Details
#attribute_groups ⇒ Hash{String => Node} (readonly)
67 68 69 |
# File 'lib/wsdl/schema/definition.rb', line 67 def attribute_groups @attribute_groups end |
#attributes ⇒ Hash{String => Node} (readonly)
64 65 66 |
# File 'lib/wsdl/schema/definition.rb', line 64 def attributes @attributes end |
#complex_types ⇒ Hash{String => Node} (readonly)
58 59 60 |
# File 'lib/wsdl/schema/definition.rb', line 58 def complex_types @complex_types end |
#element_form_default ⇒ String (readonly)
49 50 51 |
# File 'lib/wsdl/schema/definition.rb', line 49 def element_form_default @element_form_default end |
#elements ⇒ Hash{String => Node} (readonly)
55 56 57 |
# File 'lib/wsdl/schema/definition.rb', line 55 def elements @elements end |
#groups ⇒ Hash{String => Node} (readonly)
70 71 72 |
# File 'lib/wsdl/schema/definition.rb', line 70 def groups @groups end |
#import_locations ⇒ Array<String> (readonly)
76 77 78 |
# File 'lib/wsdl/schema/definition.rb', line 76 def import_locations @import_locations end |
#imports ⇒ Hash{String => String} (readonly)
73 74 75 |
# File 'lib/wsdl/schema/definition.rb', line 73 def imports @imports end |
#includes ⇒ Array<String> (readonly)
79 80 81 |
# File 'lib/wsdl/schema/definition.rb', line 79 def includes @includes end |
#simple_types ⇒ Hash{String => Node} (readonly)
61 62 63 |
# File 'lib/wsdl/schema/definition.rb', line 61 def simple_types @simple_types end |
#source_location ⇒ String? (readonly)
52 53 54 |
# File 'lib/wsdl/schema/definition.rb', line 52 def source_location @source_location end |
#target_namespace ⇒ String? (readonly)
46 47 48 |
# File 'lib/wsdl/schema/definition.rb', line 46 def target_namespace @target_namespace end |
Instance Method Details
#merge(other) ⇒ void
This method returns an undefined value.
Merges another definition's contents into this one.
Used for xs:include processing where the included schema's components should be merged as if defined locally.
Logs a warning if the other definition contains components with the same name as existing ones, since per the XSD spec xs:include components should not conflict.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/wsdl/schema/definition.rb', line 92 def merge(other) merge_with_conflict_detection(@elements, other.elements, :element) merge_with_conflict_detection(@complex_types, other.complex_types, :complex_type) merge_with_conflict_detection(@simple_types, other.simple_types, :simple_type) merge_with_conflict_detection(@attributes, other.attributes, :attribute) merge_with_conflict_detection(@attribute_groups, other.attribute_groups, :attribute_group) merge_with_conflict_detection(@groups, other.groups, :group) @imports.merge!(other.imports) @import_locations.concat(other.import_locations) @includes.concat(other.includes) end |
#release_dom_references! ⇒ void
This method returns an undefined value.
Releases all references to the Nokogiri DOM from this definition and every Node it contains.
Called by Collection#release_dom_references! after the Definition IR has been built, so the GC can reclaim the DOM trees while the collection is still reachable on the call stack.
Preserves metadata (#target_namespace, #element_form_default, component hash keys) so the definition remains inspectable.
115 116 117 118 119 |
# File 'lib/wsdl/schema/definition.rb', line 115 def release_dom_references! @schema_node = nil each_node(&:release_dom_references!) end |