forked from movitto/RXSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rxsd_test
executable file
·34 lines (27 loc) · 907 Bytes
/
rxsd_test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/ruby
# Simple rxsd test utility
#
# Usage rxsd_test uri-to-schema uri-to-xml-instance
#
# Copyright (C) 2010 Mohammed Morsi <movitto@yahoo.com>
# See COPYING for the License of this software
require 'lib/rxsd'
if ARGV.size < 2
puts "missing required arguments"
puts "usage: rxsd_test xsd_uri xml_uri"
exit
end
xsd_uri = ARGV[0]
xml_uri = ARGV[1]
schema = RXSD::Parser.parse_xsd :uri => xsd_uri
puts "=======Classes======="
classes = schema.to :ruby_classes
puts classes.collect{ |cl| !cl.nil? ? (cl.to_s + " < " + cl.superclass.to_s) : ""}.sort.join("\n")
puts "=======Tags======="
puts schema.tags.collect { |n,cb| n + ": " + cb.to_s + ": " + (cb.nil? ? "ncb" : cb.klass_name.to_s + "-" + cb.klass.to_s) }.sort.join("\n")
puts "=======Objects======="
data = RXSD::Parser.parse_xml :uri => xml_uri
objs = data.to :ruby_objects, :schema => schema
objs.each { |obj|
puts "#{obj}"
}