Class: Schematic::Generator::Types

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/generator/types.rb

Constant Summary collapse

COMPLEX =
{
  :integer => { :complex_type => "Integer", :xsd_type => "xs:integer" },
  :float => { :complex_type => "Float", :xsd_type => "xs:float" },
  :string => { :complex_type => "String", :xsd_type => "xs:string" },
  :text => { :complex_type => "Text", :xsd_type => "xs:string" },
  :datetime => { :complex_type => "DateTime", :xsd_type => "xs:dateTime" },
  :date => { :complex_type => "Date", :xsd_type => "xs:date" },
  :boolean => { :complex_type => "Boolean", :xsd_type => "xs:boolean" },
}

Class Method Summary collapse

Class Method Details

.xsd(builder) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/schematic/generator/types.rb', line 14

def self.xsd(builder)
  Types::COMPLEX.each do |key, value|
    complex_type_name = value[:complex_type]
    xsd_type = value[:xsd_type]
    builder.xs :complexType, "name" => complex_type_name do |complex_type|
      complex_type.xs :simpleContent do |simple_content|
        simple_content.xs :extension, "base" => xsd_type do |extension|
          extension.xs :attribute, "name" => "type", "type" => "xs:string", "use" => "optional"
          extension.xs :attribute, "name" => "nil", "type" => "xs:boolean", "use" => "optional"
        end
      end
    end
  end
end