Good day. The task before me is a complete parsing of the XML + schema imported + included in it. The task itself is not even a parsing of the scheme, but the receipt of element types with complete relationships. To understand the essence of the problem: schema.xsd :
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:myprefix="http://myhost.ru/service/" xmlns:anprefix="http://anotherhost.ru/pub-service/" targetNamespace="http://myhost.ru/service/"> <xs:import namespace="http://anotherhost.ru/pub-service/" schemaLocation="anotherhost_schema.xsd"/> <xs:complexType> <xs:sequence> <xs:element name="ServiceCode" type="anprefix:ServiceCodeType"> <xs:annotation> <xs:documentation>Код услуги</xs:documentation> </xs:annotation> </xs:element> <xs:element name="MessageClass" type="myprefix:MessageClassType"/> </xs:sequence> </xs:complexType> <xs:simpleType name="MessageClassType"> <xs:restriction base="xs:string"> <xs:enumeration value="REQUEST"> <xs:annotation> <xs:documentation>Запрос от потребителя к поставщику </xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="RESPONSE"> <xs:annotation> <xs:documentation>Ответ поставщика потребителю</xs:documentation> </xs:annotation> </xs:enumeration> </xs:restriction> </xs:simpleType> </xs:schema>
anotherhost_schema.xsd :
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:anprefix="http://anotherhost.ru/pub-service/" targetNamespace="http://anotherhost.ru/pub-service/"> <xs:simpleType name="ServiceCodeType"> <restriction base="xs:string"> </restriction> </xs:simpleType> </xs:schema>
The example is not very difficult, the real task is much more voluminous. What is it for me, it is necessary to disassemble the scheme and create its internal representation (for the form generator and the request handler), for example, in the following way:
{ "ServiceCode": {string, String.class, "Код услуги"}, "MessageClass": {string, {"REQUEST":"Запрос от потребителя к поставщику","RESPONSE":"Ответ поставщика потребителю"}, ""} }
Or in another, but pliable for parsing form. Is there such a library? Even if it is not open-source. The decision on my part - I will not say what is good. It is crooked and an attempt to recursion. Passing through the list of elements will not be laid out, but the analysis of the element that came up is pastebin code.
And for better perception, the diagram for this function: The diagram for the above code