How automatically identify optional attributes/elements from XML instances?

kajodawiketysyp

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 (using IntelliJ Idea tool), but it is not smart enough to recognize which elements and attributes are optional.One way to automate that would be to reverse engineer XSD from multiple XML files using the following heuristic: \[quote\] An attribute is optional (has \[code\]optional\[/code\] flag) or an element is optional (\[code\]minOccurs=0\[/code\]) if in some instances it occurs and in other does not.\[/quote\]Obviously, the heuristic would work also for a single XML file, if it 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