Hi,
I'm using Java to develop a XML-related application. One thing I need to do is that, given a XML Schema, I need to find all the element names and their types, attributes and types of attributes.
For example, if the given schema is
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="
<xs:element name="enterprise" type="EnterpriseType"/>
<xs:complexType name="EnterpriseType">
<xs:sequence>
<xs:element name="d1" type="DepartmentType"/>
<xs:element name="d2" type="DepartmentType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DepartmentType">
<xs:sequence>
<xs:element name="employee" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:schema>
Then all the elelements are:
enterprise (Type: EnterpriseType)
d1 (Type: DepartmentType, Attribute: name (Type: xs:string))
d2 (Type: DepartmentType, Attribute: name (Type: xs:string))
employee (Type: xs:string)
I tried XSOM but it only iterates the top-level elelmenents/types in the schema, I couldnt go to lower level of the schema tree.
Anyone know how I could solve this problem ? Thank you very much.
I'm using Java to develop a XML-related application. One thing I need to do is that, given a XML Schema, I need to find all the element names and their types, attributes and types of attributes.
For example, if the given schema is
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="
<xs:element name="enterprise" type="EnterpriseType"/>
<xs:complexType name="EnterpriseType">
<xs:sequence>
<xs:element name="d1" type="DepartmentType"/>
<xs:element name="d2" type="DepartmentType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DepartmentType">
<xs:sequence>
<xs:element name="employee" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:schema>
Then all the elelements are:
enterprise (Type: EnterpriseType)
d1 (Type: DepartmentType, Attribute: name (Type: xs:string))
d2 (Type: DepartmentType, Attribute: name (Type: xs:string))
employee (Type: xs:string)
I tried XSOM but it only iterates the top-level elelmenents/types in the schema, I couldnt go to lower level of the schema tree.
Anyone know how I could solve this problem ? Thank you very much.