Parse types in XML schema. Java

inconiarm

New Member
In front of me there is a problem - a complete schema parse (with include, import, redefine). The problem, is not even parsing scheme, it's to resolve types from this schema. To explain the problem, here is an example:schema.xsd:\[code\]<?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>Service code</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="http://stackoverflow.com/questions/12793326/REQUEST"> <xs:annotation> <xs:documentation>Request from client </xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="http://stackoverflow.com/questions/12793326/RESPONSE"> <xs:annotation> <xs:documentation>Response to client</xs:documentation> </xs:annotation> </xs:enumeration> </xs:restriction> </xs:simpleType></xs:schema>\[/code\]anotherhost_schema.xsd:\[code\]<?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>\[/code\]Example is not very difficult, the real problem is much bigger. My problem is to parse schema and create it's internal representation (that form generator and request handler will use), for example, as follows:\[code\]{ "ServiceCode": {"string", String.class, "Service code"}, "MessageClass": {"string", {"REQUEST":"Request from client","RESPONSE":"Response to client"}, ""}}\[/code\]Inner representation can be various, but simple for use in Java. Is there such a library? I know, that there is a library, called JAXB, created specially for XML-parsing, but I don't understand how to bind it to my problem.
 
Back
Top