Created
December 7, 2010 21:44
-
-
Save dougalcorn/732472 to your computer and use it in GitHub Desktop.
parse an xsd and pull out our complext types that extend "Entity"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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