Class: XsdReader::Schema

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/xsd_reader/schema.rb

Instance Attribute Summary

Attributes included from Shared

#options

Instance Method Summary collapse

Methods included from Shared

#[], #all_elements, #attributes, #base, #base_name, #base_namespace, #child_elements?, #choices, #class_for, #complex_content, #complex_contents, #complex_type, #complex_types, #direct_elements, #elements, #extension, #extensions, #initialize, #linked_complex_type, #linked_simple_type, #logger, #map_children, #name, #name_local, #name_referenced, #node, #node_to_object, #nodes, #object_by_name, #ordered_elements, #parent, #prepend_namespace, #ref, #referenced_element, #schema_for_namespace, #schema_namespace_prefix, #sequences, #simple_content, #simple_contents, #simple_types, #type, #type_name, #type_namespace

Instance Method Details

#import_by_namespace(ns) ⇒ Object



35
36
37
38
# File 'lib/xsd_reader/schema.rb', line 35

def import_by_namespace(ns)
  aliases = [ns, namespaces["xmlns:#{(ns || '').gsub(/^xmlns\:/, '')}"]].compact
  return imports.find{|import| aliases.include?(import.namespace)}
end

#import_mappable_children(xml_name) ⇒ Object



31
32
33
# File 'lib/xsd_reader/schema.rb', line 31

def import_mappable_children(xml_name)
  self.imports.map{|import| import.reader.schema.mappable_children(xml_name)}.flatten
end

#importsObject



21
22
23
# File 'lib/xsd_reader/schema.rb', line 21

def imports
  @imports ||= map_children("import")
end

#mappable_children(xml_name) ⇒ Object



25
26
27
28
29
# File 'lib/xsd_reader/schema.rb', line 25

def mappable_children(xml_name)
  result = super
  result += import_mappable_children(xml_name) if xml_name != 'import'
  return result.to_a
end

#namespacesObject



13
14
15
# File 'lib/xsd_reader/schema.rb', line 13

def namespaces
  self.node ? self.node.namespaces : {}
end

#schemaObject



5
6
7
# File 'lib/xsd_reader/schema.rb', line 5

def schema
  return self
end

#target_namespaceObject



9
10
11
# File 'lib/xsd_reader/schema.rb', line 9

def target_namespace
  node && node.attributes['targetNamespace'] ? node.attributes['targetNamespace'].value : nil
end

#targets_namespace?(ns) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/xsd_reader/schema.rb', line 17

def targets_namespace?(ns)
  target_namespace == ns || target_namespace == namespaces["xmlns:#{ns}"]
end