How automatically identify optional/required attributes/elements from XML instances?

websolutions

New Member
We have hundreds of XML files with no XML schema (XSD) defined in advance. I was able to generate an XSD from one of those files with a tool (IntelliJ Idea), but it is not smart enough to recognize which elements and attributes are optional and which are required.One way to automate that would be to reverse engineer XSD from multiple XML files using the following heuristic: \[quote\] An attribute/element is optional (\[code\]use="optional"\[/code\]/\[code\]minOccurs=0\[/code\]) if in some instances it occurs and in other does not. Otherwise, it is required (\[code\]use="required"\[/code\]/\[code\]minOccurs=1\[/code\]).\[/quote\]Obviously, the heuristic would work also for a single XML file, if this XML is sufficiently representative.For instance, a\[code\]flightNumber\[/code\] would be considered optional given the following input:\[code\] <list> <carrier name="BA" flightNumber="213" /> <carrier name="CY" /> </list>\[/code\]Do you know any tool to generate XSD and recognize whether an attribute/element is optional?
 
Back
Top