xml2go 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +1 -0
- data/bin/xml2go +36 -0
- data/lib/xml2go.rb +48 -0
- data/lib/xml2go/parser.rb +185 -0
- data/lib/xml2go/struct.rb +74 -0
- data/lib/xml2go/version.rb +3 -0
- data/sample.xml +326 -0
- data/xml2go.gemspec +23 -0
- metadata +90 -0
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Cesar Rodriguez
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
XML2Go
|
|
2
|
+
=========================
|
|
3
|
+
|
|
4
|
+
Convert an XML file to a Go struct.
|
|
5
|
+
|
|
6
|
+
Usage
|
|
7
|
+
-------------------------
|
|
8
|
+
bin/xml2go [options] <xml_file> <go_output_file>
|
|
9
|
+
|
|
10
|
+
Example
|
|
11
|
+
-------------------------
|
|
12
|
+
|
|
13
|
+
Input:
|
|
14
|
+
|
|
15
|
+
<?xml version="1.0"?>
|
|
16
|
+
<?xml-stylesheet type="text/css" href="nutrition.css"?>
|
|
17
|
+
<nutrition>
|
|
18
|
+
<food>
|
|
19
|
+
<name>Avocado Dip</name>
|
|
20
|
+
<mfr>Sunnydale</mfr>
|
|
21
|
+
<serving units="g">29</serving>
|
|
22
|
+
<calories total="110" fat="100"/>
|
|
23
|
+
<total-fat>11</total-fat>
|
|
24
|
+
<saturated-fat>3</saturated-fat>
|
|
25
|
+
<cholesterol>5.0</cholesterol>
|
|
26
|
+
<sodium>210</sodium>
|
|
27
|
+
<carb>2</carb>
|
|
28
|
+
<fiber>0</fiber>
|
|
29
|
+
<protein>1.1</protein>
|
|
30
|
+
<natural>false</natural>
|
|
31
|
+
</food>
|
|
32
|
+
</nutrition>
|
|
33
|
+
|
|
34
|
+
Output:
|
|
35
|
+
|
|
36
|
+
package main
|
|
37
|
+
|
|
38
|
+
type Food struct {
|
|
39
|
+
Name string `xml:"name"`
|
|
40
|
+
Mfr string `xml:"mfr"`
|
|
41
|
+
Serving int `xml:"serving"`
|
|
42
|
+
Calories string `xml:"calories"`
|
|
43
|
+
TotalFat int `xml:"total-fat"`
|
|
44
|
+
SaturatedFat int `xml:"saturated-fat"`
|
|
45
|
+
Cholesterol float64 `xml:"cholesterol"`
|
|
46
|
+
Sodium int `xml:"sodium"`
|
|
47
|
+
Carb int `xml:"carb"`
|
|
48
|
+
Fiber int `xml:"fiber"`
|
|
49
|
+
Protein float64 `xml:"protein"`
|
|
50
|
+
Natural bool `xml:"natural"`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type Nutrition struct {
|
|
54
|
+
Food Food `xml:"food"`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type Document struct {
|
|
58
|
+
Nutrition Nutrition `xml:"nutrition"`
|
|
59
|
+
}
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/xml2go
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'xml2go'
|
|
4
|
+
|
|
5
|
+
def parse_options(args)
|
|
6
|
+
@@config = {}
|
|
7
|
+
optparse = OptionParser.new do|opts|
|
|
8
|
+
opts.banner = "Usage: xml2go [options] <input_xml_file> <output_file>"
|
|
9
|
+
|
|
10
|
+
opts.on("-a", "--add-attrs", "Add XML attributes as part of the struct") do |a|
|
|
11
|
+
@@config[:add_attrs] = true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
opts.on("-p", "--plural-arrays", "Pluralize array names") do |p|
|
|
15
|
+
@@config[:plural_arrays] = true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
opts.on("-t", "--detect-type",
|
|
19
|
+
"Attempt to detect the type of a primitive by searching in the attrs") do |p|
|
|
20
|
+
@@config[:detect_type] = true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
optparse.parse!(args)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# parse the CLI args
|
|
28
|
+
parse_options(ARGV)
|
|
29
|
+
# load the XML file
|
|
30
|
+
Xml2Go::load(File.open(ARGV[-2], "r"))
|
|
31
|
+
# perform the parsing
|
|
32
|
+
Xml2Go::parse(@@config)
|
|
33
|
+
# print the results
|
|
34
|
+
Xml2Go::write_to_file(ARGV[-1])
|
|
35
|
+
# format the results
|
|
36
|
+
v = `gofmt -w --tabs=false --tabwidth=4 #{ARGV[-1]}`
|
data/lib/xml2go.rb
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require "nokogiri"
|
|
2
|
+
require "optparse"
|
|
3
|
+
|
|
4
|
+
require 'xml2go/struct'
|
|
5
|
+
require 'xml2go/parser'
|
|
6
|
+
|
|
7
|
+
module Xml2Go
|
|
8
|
+
|
|
9
|
+
def self.get_const_name(str)
|
|
10
|
+
final_str = ""
|
|
11
|
+
return str.gsub(/([A-Z])/){|c| "_#{c}"}.gsub(/^_/, "").upcase
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.load(file_handle)
|
|
15
|
+
@@doc = Nokogiri::XML(file_handle)
|
|
16
|
+
@@structs = {}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.parse(config)
|
|
20
|
+
@@config = config
|
|
21
|
+
parse_element(@@doc)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.parse_element(element)
|
|
25
|
+
@@parser = Xml2Go::Parser.new(@@config)
|
|
26
|
+
@@parser.parse_element(element)
|
|
27
|
+
@@structs = @@parser.structs
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.write_to_file(filename)
|
|
32
|
+
file_handle = File.new(filename, "w")
|
|
33
|
+
file_handle.write("package main\n\n")
|
|
34
|
+
file_handle.write(@@structs.values.join("\n"))
|
|
35
|
+
file_handle.close()
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.write_mocks_to_file(filename)
|
|
39
|
+
file_handle = File.new(filename, "w")
|
|
40
|
+
file_handle.write("package main\n\n")
|
|
41
|
+
consts = @@structs.values.map{ |v| v.get_consts }
|
|
42
|
+
file_handle.write(consts.join("\n"))
|
|
43
|
+
blobs = @@structs.values.map { |v| v.to_declaration}
|
|
44
|
+
file_handle.write(blobs.join("\n"))
|
|
45
|
+
file_handle.close()
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
|
|
2
|
+
module Xml2Go
|
|
3
|
+
|
|
4
|
+
class Parser
|
|
5
|
+
|
|
6
|
+
SUPPORTED_TYPES = ["bool", "int", "float64", "string"]
|
|
7
|
+
INVALID_CHARS = ["-"]
|
|
8
|
+
|
|
9
|
+
attr_reader :structs
|
|
10
|
+
|
|
11
|
+
def initialize(config)
|
|
12
|
+
@config = config
|
|
13
|
+
@structs = {}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# ruby's .capitalize ignores Camel case
|
|
17
|
+
def cap(s)
|
|
18
|
+
s[0] = s[0].upcase
|
|
19
|
+
return s
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# ruby's .capitalize ignores Camel case
|
|
24
|
+
def low(s)
|
|
25
|
+
dup = s.dup
|
|
26
|
+
dup[0] = dup[0].downcase
|
|
27
|
+
return dup
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# remove invalid chars, capitalize and camelcase it
|
|
32
|
+
def normalize(s)
|
|
33
|
+
s = cap(s)
|
|
34
|
+
INVALID_CHARS.each do |char|
|
|
35
|
+
s.gsub!(char, "_")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
return s.gsub(/(?<=_|^)(\w)/){$1.upcase}.gsub(/(?:_)(\w)/,'\1')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def numeric?(str)
|
|
42
|
+
Float(str) != nil rescue false
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# take 's' out of string and return if it was plural or not
|
|
46
|
+
def singularize(string)
|
|
47
|
+
return [string, false]
|
|
48
|
+
if string[-1] == "s" then
|
|
49
|
+
string = string[0..-2]
|
|
50
|
+
return [string, true]
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def get_struct_member(element)
|
|
55
|
+
type = normalize(element.name)
|
|
56
|
+
var_name = type
|
|
57
|
+
xml_tag = element.name
|
|
58
|
+
[var_name, type, xml_tag]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def add_field_to_struct(struct, var_name, type, xml_tag)
|
|
62
|
+
if struct.fields.has_key?(var_name) &&
|
|
63
|
+
!struct.fields[var_name].type.include?("[]") then
|
|
64
|
+
|
|
65
|
+
type = struct.fields[var_name].type
|
|
66
|
+
# Ignore the 's' at the end
|
|
67
|
+
if type[-1] == "s" then
|
|
68
|
+
# update the struct
|
|
69
|
+
@structs[type].name = type[0..-2]
|
|
70
|
+
type = type[0..-2]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
struct.fields[var_name].type = "[]" + type
|
|
74
|
+
|
|
75
|
+
if @config[:plural_arrays] then
|
|
76
|
+
struct.fields[var_name].name << "s" if struct.fields[var_name].name[-1] != "s"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
else
|
|
80
|
+
struct.add_field(var_name, type, xml_tag)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# adds the XML attrs of element to the Go struct
|
|
85
|
+
def add_attrs_to_struct(element, struct)
|
|
86
|
+
if element.respond_to?(:attributes) then
|
|
87
|
+
element.attributes.each do |attri, value|
|
|
88
|
+
var_name = attri.dup
|
|
89
|
+
add_field_to_struct(struct, normalize(var_name), get_type(value.text), "#{attri},attr")
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Add XML node, which contains more child nodes, as a member struct
|
|
95
|
+
def add_xml_node(element, struct)
|
|
96
|
+
var_name, type, xml_tag = get_struct_member(element)
|
|
97
|
+
|
|
98
|
+
type, plural = singularize(type)
|
|
99
|
+
type = "[]" + type if plural
|
|
100
|
+
|
|
101
|
+
begin
|
|
102
|
+
xml_tag = element.namespace.prefix << ":" << xml_tag
|
|
103
|
+
rescue => e
|
|
104
|
+
# :)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
add_field_to_struct(struct, var_name, type, xml_tag)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Add XML node, which contains no child nodes, as a primitive type
|
|
111
|
+
# if it contains attrs, add it as a struct.
|
|
112
|
+
def add_xml_primitive(element, struct)
|
|
113
|
+
var_name, type, xml_tag = get_struct_member(element)
|
|
114
|
+
|
|
115
|
+
# is this a primitive with attrs?
|
|
116
|
+
prim_attrs = element.attributes.select{ |k,v| !k.include?("type") }
|
|
117
|
+
if prim_attrs.length > 0 then
|
|
118
|
+
|
|
119
|
+
add_field_to_struct(struct, var_name, type, xml_tag)
|
|
120
|
+
parse_element(element)
|
|
121
|
+
else
|
|
122
|
+
|
|
123
|
+
type = get_type_from_elem(element)
|
|
124
|
+
add_field_to_struct(struct, var_name, type, xml_tag)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def parse_element(element)
|
|
129
|
+
struct_name = normalize(element.name)
|
|
130
|
+
# TODO: maybe we DO want to process repeated structs
|
|
131
|
+
# to capture arrays don't process to structs
|
|
132
|
+
return if @structs.has_key?(struct_name)
|
|
133
|
+
|
|
134
|
+
struct = Xml2Go::Struct.new(struct_name)
|
|
135
|
+
|
|
136
|
+
# add attributes as properties
|
|
137
|
+
if @config[:add_attrs] then
|
|
138
|
+
add_attrs_to_struct(element, struct)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
element.elements.each do |child|
|
|
142
|
+
# this is a struct
|
|
143
|
+
if child.elements.count > 0 then
|
|
144
|
+
add_xml_node(child, struct)
|
|
145
|
+
parse_element(child)
|
|
146
|
+
|
|
147
|
+
else # this is an XML primitive
|
|
148
|
+
add_xml_primitive(child, struct)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
@structs[struct.name] = struct
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# analyses the xml element to try and fetch the type
|
|
156
|
+
# if can't figure it out, returns 'string'
|
|
157
|
+
def get_type_from_elem(element)
|
|
158
|
+
|
|
159
|
+
if @config[:detect_type] then
|
|
160
|
+
# check and see if the type is provided in the attributes
|
|
161
|
+
element.attributes.each do |k,v|
|
|
162
|
+
if k.include?("type") then
|
|
163
|
+
type = v.value.split(":").last
|
|
164
|
+
return type if SUPPORTED_TYPES.include?(type)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
return get_type(element.child.to_s)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def get_type(string)
|
|
173
|
+
# try to figure out the type
|
|
174
|
+
if numeric?(string) then
|
|
175
|
+
return "float64" if Float(string).to_s.length == string.length
|
|
176
|
+
return "int"
|
|
177
|
+
end
|
|
178
|
+
return "bool" if ["true", "false"].include?(string)
|
|
179
|
+
return "string"
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
module Xml2Go
|
|
3
|
+
|
|
4
|
+
# class representing a Go struct
|
|
5
|
+
class Struct
|
|
6
|
+
attr_accessor :fields, :name
|
|
7
|
+
|
|
8
|
+
# represents member variables
|
|
9
|
+
class Field
|
|
10
|
+
attr_accessor :type, :name, :xml_tag, :value
|
|
11
|
+
|
|
12
|
+
def initialize(name, type, xml_tag, value)
|
|
13
|
+
@name = name
|
|
14
|
+
@type = type
|
|
15
|
+
@xml_tag = xml_tag
|
|
16
|
+
@value = value
|
|
17
|
+
@const_name = Xml2Go::get_const_name(@name)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_s
|
|
21
|
+
"#{@name} #{@type} `xml:\"#{@xml_tag}\"`"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_declaration
|
|
25
|
+
value = @value.nil? ? Xml2Go::low(@name) : @const_name
|
|
26
|
+
"#{@name}: #{value},"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def to_const
|
|
30
|
+
if !value.nil? then
|
|
31
|
+
return "#{@const_name} = \"#{@value}\""
|
|
32
|
+
end
|
|
33
|
+
return ""
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def initialize(name)
|
|
39
|
+
@name = name
|
|
40
|
+
@fields = {}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# adds member variable to struct
|
|
44
|
+
def add_field(var_name, type, xml_tag, value=nil)
|
|
45
|
+
@fields[var_name] = Field.new(var_name, type, xml_tag, value)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# adds member variable to struct
|
|
49
|
+
def delete_field(var_name)
|
|
50
|
+
@fields.delete(var_name)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def to_s
|
|
54
|
+
fields_string = @fields.values.join("\n")
|
|
55
|
+
"type #{@name} struct {\n
|
|
56
|
+
#{fields_string}
|
|
57
|
+
}
|
|
58
|
+
"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def to_declaration
|
|
62
|
+
fields_string = @fields.values.map { |v| v.to_declaration}
|
|
63
|
+
"#{Xml2Go::low(@name)} := #{@name} {
|
|
64
|
+
#{fields_string.join("\n")}
|
|
65
|
+
}"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def get_consts
|
|
69
|
+
consts_string = @fields.values.map{ |v| v.to_const}
|
|
70
|
+
"// #{@name} info \n" << consts_string.join("\n")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|
data/sample.xml
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<soap:Envelope
|
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4
|
+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
|
5
|
+
xmlns:vin="http://soap.vindicia.com/v4_0/Vindicia"
|
|
6
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
7
|
+
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
|
8
|
+
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
9
|
+
<soap:Body>
|
|
10
|
+
<fetchAllResponse xmlns="http://soap.vindicia.com/v4_0/Product">
|
|
11
|
+
<return xmlns="" xsi:type="vin:Return">
|
|
12
|
+
<returnCode xsi:type="vin:ReturnCode">200</returnCode>
|
|
13
|
+
|
|
14
|
+
<soapId xsi:type="xsd:string">1d6427aec1200109f81806a271d0199cc0c6f3ca</soapId>
|
|
15
|
+
|
|
16
|
+
<returnString xsi:type="xsd:string">OK</returnString>
|
|
17
|
+
</return>
|
|
18
|
+
|
|
19
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
20
|
+
<VID xmlns="" xsi:type="xsd:string">2ececbcefe8f018f2ef95005787d61f90eba5fbc</VID>
|
|
21
|
+
|
|
22
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">standard_product</merchantProductId>
|
|
23
|
+
|
|
24
|
+
<descriptions xmlns="" xsi:type="vin:ProductDescription">
|
|
25
|
+
<language xmlns="" xsi:type="xsd:string">EN</language>
|
|
26
|
+
|
|
27
|
+
<description xmlns="" xsi:type="xsd:string">Standard product</description>
|
|
28
|
+
</descriptions>
|
|
29
|
+
|
|
30
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Active</status>
|
|
31
|
+
|
|
32
|
+
<taxClassification xmlns="" xsi:type="vin:TaxClassification">OtherTaxable</taxClassification>
|
|
33
|
+
|
|
34
|
+
<defaultBillingPlan xmlns="" xsi:type="vin:BillingPlan">
|
|
35
|
+
<VID xmlns="" xsi:type="xsd:string">b105366817bbd96ecfd8c9af5d9a5a3d065b8e81</VID>
|
|
36
|
+
|
|
37
|
+
<merchantBillingPlanId xmlns="" xsi:type="xsd:string">standard_billing</merchantBillingPlanId>
|
|
38
|
+
|
|
39
|
+
<description xmlns="" xsi:type="xsd:string">Standard access</description>
|
|
40
|
+
|
|
41
|
+
<status xmlns="" xsi:type="vin:BillingPlanStatus">Active</status>
|
|
42
|
+
|
|
43
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
44
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
45
|
+
|
|
46
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
47
|
+
|
|
48
|
+
<cycles xmlns="" xsi:type="xsd:int">1</cycles>
|
|
49
|
+
|
|
50
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
51
|
+
<amount xmlns="" xsi:type="xsd:decimal">0</amount>
|
|
52
|
+
|
|
53
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
54
|
+
</prices>
|
|
55
|
+
|
|
56
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
57
|
+
|
|
58
|
+
<free xmlns="" xsi:type="xsd:boolean">1</free>
|
|
59
|
+
</periods>
|
|
60
|
+
|
|
61
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
62
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
63
|
+
|
|
64
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
65
|
+
|
|
66
|
+
<cycles xmlns="" xsi:type="xsd:int">0</cycles>
|
|
67
|
+
|
|
68
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
69
|
+
<amount xmlns="" xsi:type="xsd:decimal">50</amount>
|
|
70
|
+
|
|
71
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
72
|
+
</prices>
|
|
73
|
+
|
|
74
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
75
|
+
</periods>
|
|
76
|
+
|
|
77
|
+
<prenotifyDays xmlns="" xsi:type="xsd:int">4</prenotifyDays>
|
|
78
|
+
|
|
79
|
+
<merchantEntitlementIds xmlns="" xsi:type="vin:MerchantEntitlementId">
|
|
80
|
+
<id xmlns="" xsi:type="xsd:string">standard_entitlement&amp;#39;</id>
|
|
81
|
+
</merchantEntitlementIds>
|
|
82
|
+
|
|
83
|
+
<billingStatementIdentifier xmlns="" xsi:type="xsd:string">Seymore.tv</billingStatementIdentifier>
|
|
84
|
+
</defaultBillingPlan>
|
|
85
|
+
|
|
86
|
+
<creditGranted xmlns="" xsi:type="vin:Credit" />
|
|
87
|
+
</products>
|
|
88
|
+
|
|
89
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
90
|
+
<VID xmlns="" xsi:type="xsd:string">5e156ffa360f716c2f359d3b9820d7d7d64001ed</VID>
|
|
91
|
+
|
|
92
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">Omar_test</merchantProductId>
|
|
93
|
+
|
|
94
|
+
<descriptions xmlns="" xsi:type="vin:ProductDescription">
|
|
95
|
+
<language xmlns="" xsi:type="xsd:string">EN</language>
|
|
96
|
+
|
|
97
|
+
<description xmlns="" xsi:type="xsd:string">Testing</description>
|
|
98
|
+
</descriptions>
|
|
99
|
+
|
|
100
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Active</status>
|
|
101
|
+
|
|
102
|
+
<taxClassification xmlns="" xsi:type="vin:TaxClassification">OtherTaxable</taxClassification>
|
|
103
|
+
|
|
104
|
+
<creditGranted xmlns="" xsi:type="vin:Credit" />
|
|
105
|
+
</products>
|
|
106
|
+
|
|
107
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
108
|
+
<VID xmlns="" xsi:type="xsd:string">d257eada072f0f88f3a74d66c8d8cffccd5b70b1</VID>
|
|
109
|
+
|
|
110
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">my_product</merchantProductId>
|
|
111
|
+
|
|
112
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Active</status>
|
|
113
|
+
</products>
|
|
114
|
+
|
|
115
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
116
|
+
<VID xmlns="" xsi:type="xsd:string">28e49460f07de9ae6689a89605764a0522f00700</VID>
|
|
117
|
+
|
|
118
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">pepe</merchantProductId>
|
|
119
|
+
|
|
120
|
+
<descriptions xmlns="" xsi:type="vin:ProductDescription">
|
|
121
|
+
<language xmlns="" xsi:type="xsd:string">EN</language>
|
|
122
|
+
|
|
123
|
+
<description xmlns="" xsi:type="xsd:string">Standard product</description>
|
|
124
|
+
</descriptions>
|
|
125
|
+
|
|
126
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Suspended</status>
|
|
127
|
+
</products>
|
|
128
|
+
|
|
129
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
130
|
+
<VID xmlns="" xsi:type="xsd:string">621cd6a05344936fe9046abe68b67441a271ef93</VID>
|
|
131
|
+
|
|
132
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">aaaapepe</merchantProductId>
|
|
133
|
+
|
|
134
|
+
<descriptions xmlns="" xsi:type="vin:ProductDescription">
|
|
135
|
+
<language xmlns="" xsi:type="xsd:string">EN</language>
|
|
136
|
+
|
|
137
|
+
<description xmlns="" xsi:type="xsd:string">Standard product</description>
|
|
138
|
+
</descriptions>
|
|
139
|
+
|
|
140
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Active</status>
|
|
141
|
+
</products>
|
|
142
|
+
|
|
143
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
144
|
+
<VID xmlns="" xsi:type="xsd:string">4bebf3e91ae660fc34acf13b28b0c4881293385e</VID>
|
|
145
|
+
|
|
146
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">omar2</merchantProductId>
|
|
147
|
+
|
|
148
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Active</status>
|
|
149
|
+
|
|
150
|
+
<defaultBillingPlan xmlns="" xsi:type="vin:BillingPlan">
|
|
151
|
+
<VID xmlns="" xsi:type="xsd:string">0cea0648d9cb8533c24180118383c6ad72ad2ff9</VID>
|
|
152
|
+
|
|
153
|
+
<merchantBillingPlanId xmlns="" xsi:type="xsd:string">odion_default_billing_plan</merchantBillingPlanId>
|
|
154
|
+
|
|
155
|
+
<description xmlns="" xsi:type="xsd:string">Billing Plan used for Odion product.</description>
|
|
156
|
+
|
|
157
|
+
<status xmlns="" xsi:type="vin:BillingPlanStatus">Active</status>
|
|
158
|
+
|
|
159
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
160
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
161
|
+
|
|
162
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
163
|
+
|
|
164
|
+
<cycles xmlns="" xsi:type="xsd:int">1</cycles>
|
|
165
|
+
|
|
166
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
167
|
+
<amount xmlns="" xsi:type="xsd:decimal">0</amount>
|
|
168
|
+
|
|
169
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
170
|
+
</prices>
|
|
171
|
+
|
|
172
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
173
|
+
|
|
174
|
+
<free xmlns="" xsi:type="xsd:boolean">1</free>
|
|
175
|
+
</periods>
|
|
176
|
+
|
|
177
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
178
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
179
|
+
|
|
180
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
181
|
+
|
|
182
|
+
<cycles xmlns="" xsi:type="xsd:int">0</cycles>
|
|
183
|
+
|
|
184
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
185
|
+
<amount xmlns="" xsi:type="xsd:decimal">50</amount>
|
|
186
|
+
|
|
187
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
188
|
+
</prices>
|
|
189
|
+
|
|
190
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
191
|
+
|
|
192
|
+
<free xmlns="" xsi:type="xsd:boolean">0</free>
|
|
193
|
+
</periods>
|
|
194
|
+
</defaultBillingPlan>
|
|
195
|
+
</products>
|
|
196
|
+
|
|
197
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
198
|
+
<VID xmlns="" xsi:type="xsd:string">42442538413503c041b3654d01339b11adeb7879</VID>
|
|
199
|
+
|
|
200
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">odion_product</merchantProductId>
|
|
201
|
+
|
|
202
|
+
<descriptions xmlns="" xsi:type="vin:ProductDescription">
|
|
203
|
+
<language xmlns="" xsi:type="xsd:string">EN</language>
|
|
204
|
+
|
|
205
|
+
<description xmlns="" xsi:type="xsd:string">Test Product for Odion Account</description>
|
|
206
|
+
</descriptions>
|
|
207
|
+
|
|
208
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Active</status>
|
|
209
|
+
|
|
210
|
+
<defaultBillingPlan xmlns="" xsi:type="vin:BillingPlan">
|
|
211
|
+
<VID xmlns="" xsi:type="xsd:string">0cea0648d9cb8533c24180118383c6ad72ad2ff9</VID>
|
|
212
|
+
|
|
213
|
+
<merchantBillingPlanId xmlns="" xsi:type="xsd:string">odion_default_billing_plan</merchantBillingPlanId>
|
|
214
|
+
|
|
215
|
+
<description xmlns="" xsi:type="xsd:string">Billing Plan used for Odion product.</description>
|
|
216
|
+
|
|
217
|
+
<status xmlns="" xsi:type="vin:BillingPlanStatus">Active</status>
|
|
218
|
+
|
|
219
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
220
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
221
|
+
|
|
222
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
223
|
+
|
|
224
|
+
<cycles xmlns="" xsi:type="xsd:int">1</cycles>
|
|
225
|
+
|
|
226
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
227
|
+
<amount xmlns="" xsi:type="xsd:decimal">0</amount>
|
|
228
|
+
|
|
229
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
230
|
+
</prices>
|
|
231
|
+
|
|
232
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
233
|
+
|
|
234
|
+
<free xmlns="" xsi:type="xsd:boolean">1</free>
|
|
235
|
+
</periods>
|
|
236
|
+
|
|
237
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
238
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
239
|
+
|
|
240
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
241
|
+
|
|
242
|
+
<cycles xmlns="" xsi:type="xsd:int">0</cycles>
|
|
243
|
+
|
|
244
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
245
|
+
<amount xmlns="" xsi:type="xsd:decimal">50</amount>
|
|
246
|
+
|
|
247
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
248
|
+
</prices>
|
|
249
|
+
|
|
250
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
251
|
+
|
|
252
|
+
<free xmlns="" xsi:type="xsd:boolean">0</free>
|
|
253
|
+
</periods>
|
|
254
|
+
</defaultBillingPlan>
|
|
255
|
+
</products>
|
|
256
|
+
|
|
257
|
+
<products xmlns="" xsi:type="vin:Product">
|
|
258
|
+
<VID xmlns="" xsi:type="xsd:string">910533526550db530999c729e4e94d82fca819e7</VID>
|
|
259
|
+
|
|
260
|
+
<merchantProductId xmlns="" xsi:type="xsd:string">main_product</merchantProductId>
|
|
261
|
+
|
|
262
|
+
<descriptions xmlns="" xsi:type="vin:ProductDescription">
|
|
263
|
+
<language xmlns="" xsi:type="xsd:string">EN</language>
|
|
264
|
+
|
|
265
|
+
<description xmlns="" xsi:type="xsd:string">Test Product for Odion Account</description>
|
|
266
|
+
</descriptions>
|
|
267
|
+
|
|
268
|
+
<status xmlns="" xsi:type="vin:ProductStatus">Active</status>
|
|
269
|
+
|
|
270
|
+
<defaultBillingPlan xmlns="" xsi:type="vin:BillingPlan">
|
|
271
|
+
<VID xmlns="" xsi:type="xsd:string">0cea0648d9cb8533c24180118383c6ad72ad2ff9</VID>
|
|
272
|
+
|
|
273
|
+
<merchantBillingPlanId xmlns="" xsi:type="xsd:string">odion_default_billing_plan</merchantBillingPlanId>
|
|
274
|
+
|
|
275
|
+
<description xmlns="" xsi:type="xsd:string">Billing Plan used for Odion product.</description>
|
|
276
|
+
|
|
277
|
+
<status xmlns="" xsi:type="vin:BillingPlanStatus">Active</status>
|
|
278
|
+
|
|
279
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
280
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
281
|
+
|
|
282
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
283
|
+
|
|
284
|
+
<cycles xmlns="" xsi:type="xsd:int">1</cycles>
|
|
285
|
+
|
|
286
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
287
|
+
<amount xmlns="" xsi:type="xsd:decimal">0</amount>
|
|
288
|
+
|
|
289
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
290
|
+
</prices>
|
|
291
|
+
|
|
292
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
293
|
+
|
|
294
|
+
<free xmlns="" xsi:type="xsd:boolean">1</free>
|
|
295
|
+
</periods>
|
|
296
|
+
|
|
297
|
+
<periods xmlns="" xsi:type="vin:BillingPlanPeriod">
|
|
298
|
+
<type xmlns="" xsi:type="vin:BillingPeriodType">Month</type>
|
|
299
|
+
|
|
300
|
+
<quantity xmlns="" xsi:type="xsd:int">1</quantity>
|
|
301
|
+
|
|
302
|
+
<cycles xmlns="" xsi:type="xsd:int">0</cycles>
|
|
303
|
+
|
|
304
|
+
<prices xmlns="" xsi:type="vin:BillingPlanPrice">
|
|
305
|
+
<amount xmlns="" xsi:type="xsd:decimal">50</amount>
|
|
306
|
+
|
|
307
|
+
<currency xmlns="" xsi:type="xsd:string">USD</currency>
|
|
308
|
+
</prices>
|
|
309
|
+
|
|
310
|
+
<doNotNotifyFirstBill xmlns="" xsi:type="xsd:boolean">1</doNotNotifyFirstBill>
|
|
311
|
+
|
|
312
|
+
<free xmlns="" xsi:type="xsd:boolean">0</free>
|
|
313
|
+
</periods>
|
|
314
|
+
</defaultBillingPlan>
|
|
315
|
+
|
|
316
|
+
<merchantEntitlementIds xmlns="" xsi:type="vin:MerchantEntitlementId">
|
|
317
|
+
<id xmlns="" xsi:type="xsd:string">main_entitlement</id>
|
|
318
|
+
|
|
319
|
+
<description xmlns="" xsi:type="xsd:string">Main Product Entitlement</description>
|
|
320
|
+
</merchantEntitlementIds>
|
|
321
|
+
|
|
322
|
+
<creditGranted xmlns="" xsi:type="vin:Credit" />
|
|
323
|
+
</products>
|
|
324
|
+
</fetchAllResponse>
|
|
325
|
+
</soap:Body>
|
|
326
|
+
</soap:Envelope>
|
data/xml2go.gemspec
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'xml2go/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "xml2go"
|
|
8
|
+
spec.version = Xml2go::VERSION
|
|
9
|
+
spec.authors = ["Cesar Rodriguez"]
|
|
10
|
+
spec.email = ["cesar@ooyala.com"]
|
|
11
|
+
spec.summary = %q{Convert XML to Go structs}
|
|
12
|
+
spec.description = ""
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = "xml2go"
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: xml2go
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Cesar Rodriguez
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '1.5'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '1.5'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rake
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
description: ''
|
|
47
|
+
email:
|
|
48
|
+
- cesar@ooyala.com
|
|
49
|
+
executables:
|
|
50
|
+
- xml2go
|
|
51
|
+
extensions: []
|
|
52
|
+
extra_rdoc_files: []
|
|
53
|
+
files:
|
|
54
|
+
- Gemfile
|
|
55
|
+
- LICENSE.txt
|
|
56
|
+
- README.md
|
|
57
|
+
- Rakefile
|
|
58
|
+
- bin/xml2go
|
|
59
|
+
- lib/xml2go.rb
|
|
60
|
+
- lib/xml2go/parser.rb
|
|
61
|
+
- lib/xml2go/struct.rb
|
|
62
|
+
- lib/xml2go/version.rb
|
|
63
|
+
- sample.xml
|
|
64
|
+
- xml2go.gemspec
|
|
65
|
+
homepage: ''
|
|
66
|
+
licenses:
|
|
67
|
+
- MIT
|
|
68
|
+
post_install_message:
|
|
69
|
+
rdoc_options: []
|
|
70
|
+
require_paths:
|
|
71
|
+
- lib
|
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
|
+
none: false
|
|
80
|
+
requirements:
|
|
81
|
+
- - ! '>='
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
84
|
+
requirements: []
|
|
85
|
+
rubyforge_project:
|
|
86
|
+
rubygems_version: 1.8.23
|
|
87
|
+
signing_key:
|
|
88
|
+
specification_version: 3
|
|
89
|
+
summary: Convert XML to Go structs
|
|
90
|
+
test_files: []
|