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.
-
#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.
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 |
# 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 = {} @imports = {} @includes = [] parse end |
Instance Attribute Details
#attribute_groups ⇒ Hash{String => Node} (readonly)
Returns attribute group definitions.
65 66 67 |
# File 'lib/wsdl/schema/definition.rb', line 65 def attribute_groups @attribute_groups end |
#attributes ⇒ Hash{String => Node} (readonly)
Returns global attribute declarations.
62 63 64 |
# File 'lib/wsdl/schema/definition.rb', line 62 def attributes @attributes end |
#complex_types ⇒ Hash{String => Node} (readonly)
Returns complex type definitions.
56 57 58 |
# File 'lib/wsdl/schema/definition.rb', line 56 def complex_types @complex_types end |
#element_form_default ⇒ String (readonly)
Returns 'qualified' or 'unqualified'.
47 48 49 |
# File 'lib/wsdl/schema/definition.rb', line 47 def element_form_default @element_form_default end |
#elements ⇒ Hash{String => Node} (readonly)
Returns global element declarations.
53 54 55 |
# File 'lib/wsdl/schema/definition.rb', line 53 def elements @elements end |
#imports ⇒ Hash{String => String} (readonly)
Returns namespace to schemaLocation mappings.
68 69 70 |
# File 'lib/wsdl/schema/definition.rb', line 68 def imports @imports end |
#includes ⇒ Array<String> (readonly)
Returns schemaLocation values for includes.
71 72 73 |
# File 'lib/wsdl/schema/definition.rb', line 71 def includes @includes end |
#simple_types ⇒ Hash{String => Node} (readonly)
Returns simple type definitions.
59 60 61 |
# File 'lib/wsdl/schema/definition.rb', line 59 def simple_types @simple_types end |
#source_location ⇒ String? (readonly)
Returns the location this schema was loaded from.
50 51 52 |
# File 'lib/wsdl/schema/definition.rb', line 50 def source_location @source_location end |
#target_namespace ⇒ String? (readonly)
Returns the target namespace URI.
44 45 46 |
# File 'lib/wsdl/schema/definition.rb', line 44 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.
84 85 86 87 88 89 90 91 92 |
# File 'lib/wsdl/schema/definition.rb', line 84 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) @imports.merge!(other.imports) @includes.concat(other.includes) end |