Skip to content

Instantly share code, notes, and snippets.

@dougalcorn
Created December 7, 2010 21:44
Show Gist options
  • Save dougalcorn/732472 to your computer and use it in GitHub Desktop.
Save dougalcorn/732472 to your computer and use it in GitHub Desktop.
parse an xsd and pull out our complext types that extend "Entity"
filename = Rails.root.join("2-XML Schema", "[OSA-EAI-CCOM-ML-XSD-V03-2]CCOM-ML_V3-2-3 (2010-11-30).xsd")
doc = Nokogiri::XML(File.read(filename))
def complex_types_of(doc,base)
hash = {}
doc.xpath("//xs:extension[@base='#{base}']").each do |extension|
complex_type = extension.parent.parent
name = complex_type[:name]
hash[name] = complex_types_of(doc,name)
end
hash
end
entities = {:entity => complex_types_of(doc, "Entity")}
puts entities.to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment