class Sekken::XS::Schema

Attributes

attribute_groups[RW]
attributes[RW]
complex_types[RW]
element_form_default[RW]
elements[RW]
imports[RW]
simple_types[RW]
target_namespace[RW]

Public Class Methods

new(schema, schemas) click to toggle source
# File lib/sekken/xs/schema.rb, line 7
def initialize(schema, schemas)
  @schema = schema
  @schemas = schemas

  @target_namespace     = @schema['targetNamespace']
  @element_form_default = @schema['elementFormDefault'] || 'unqualified'

  @attributes       = {}
  @attribute_groups = {}
  @elements         = {}
  @complex_types    = {}
  @simple_types     = {}
  @imports          = {}

  parse
end

Private Instance Methods

parse() click to toggle source
# File lib/sekken/xs/schema.rb, line 29
def parse
  schema = {
    :target_namespace => @target_namespace,
    :element_form_default => @element_form_default
  }

  @schema.element_children.each do |node|
    case node.name
    when 'attribute'      then store_element(@attributes, node, schema)
    when 'attributeGroup' then store_element(@attribute_groups, node, schema)
    when 'element'        then store_element(@elements, node, schema)
    when 'complexType'    then store_element(@complex_types, node, schema)
    when 'simpleType'     then store_element(@simple_types, node, schema)
    when 'import'         then store_import(node)
    end
  end
end
store_element(collection, node, schema) click to toggle source
# File lib/sekken/xs/schema.rb, line 47
def store_element(collection, node, schema)
  collection[node['name']] = XS.build(node, @schemas, schema)
end
store_import(node) click to toggle source
# File lib/sekken/xs/schema.rb, line 51
def store_import(node)
  @imports[node['namespace']] = node['schemaLocation']
end