how to get max depth of a xsd using xsom.
For e.g: total number of elements under each complex types of the xsd?
Also if as complex types is there under that complex types the number of element + attributes under that……using dom\xsom\jaxb
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="root" type="root">
<xs:annotation>
<xs:documentation>
Comment describing your root element
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="root">
<xs:sequence>
<xs:element name="element_count" type="xs:string"></xs:element>
<xs:element name="employee" type="employee" maxOccurs="unbounded" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="employee">
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:element name="ID" type="xs:string"></xs:element>
<xs:element name="Addresses" type="addresses" maxOccurs="1" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addresses">
<xs:sequence>
<xs:element name="address" type="address" maxOccurs="unbounded" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="address">
<xs:sequence>
<xs:element name="line1" type="xs:string"></xs:element>
<xs:element name="line2" type="xs:string"></xs:element>
<xs:element name="city" type="xs:string"></xs:element>
<xs:element name="type" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
I was actually just looking for this. I could not find anything in the API, so found a way with recursion yesterday. I am simply pasting my recursive way to read to the deepest and add them into a Hashmap.