lib/dslize/formatter/xsd_formatter.rb in dslize-0.0.4 vs lib/dslize/formatter/xsd_formatter.rb in dslize-0.0.5
- old
+ new
@@ -25,10 +25,15 @@
subclasses = get_subclasses(clazz)
if subclasses.empty?
xsd.element(nil, { :ref => clazz, :maxOccurs => max_occurs }.select { |k,v| !v.nil? })
else
xsd.choice({ :maxOccurs => max_occurs }.select { |k,v| !v.nil? }) do
+ xsd.annotation do
+ xsd.appinfo do
+ xsd.property :name => clazz, :xmlns => "http://java.sun.com/xml/ns/jaxb"
+ end
+ end
subclasses.each do |sub_type|
xsd.element(nil, :ref => sub_type)
end
if !objects[clazz][:abstract]
xsd.element(nil, :ref => clazz)
@@ -51,10 +56,11 @@
end
end
end
File.open(args[0], "w") do |f|
- f << schema.to_xml.gsub(' name=""', '') # xpain is buggy and always write a name on <element>
+ f << schema.to_xml.gsub(' name=""', ''). # xpain is buggy and always write a name on <element>
+ gsub(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"', ' xmlns:xsd="http://www.w3.org/2001/XMLSchema" jaxb:version="2.0" elementFormDefault="qualified" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"')
end
end
private
def extends_base_if_needed(xsd, parent)