This week's book giveaway is in the Java in General forum. We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line! See this thread for details.
XSD Parser, XML Parsers doesn't work because XSD can be written different ways
posted 5 years ago
I want to find the root Type of the XSD ( You know the root node of the corresponding XML, But I don't have it's XML, just XSD)
I need to identify the root type, The normal XML ( XSD also a type of XML) doesn't work simply because you can write same XSD in different ways.
I have been looking at a few of mine, and I think if you only have the XSD you may have to go back to basics -- the root tag has no REQUIRED identifying mark -- it is the only element tag that is neither a simple element nor contained within another complex element.
So use old-fashioned W3C DOM and parse your XSD as normal XML, then walk the tree and build a Map of all the element names, then walk the tree again and delete from the map:
-- all simple elements
-- all elements that occur inside another element.
You should be left with one element in your Map ...