How to load XML tags order from XSD with Java?

Raad

New Member
I have a question:I. QUESTIONIs there a way/Java-based library by which I can retrieve the order of the XML elements by reading/loading its XSD (in advance)?II. BACKGROUNDThe app I am working on should generate various types of XMLs (feeds), each of which based on a given schema (XSD). The point is that I can't use the standard approach for serialization - JAXB, as I should generate/stream the XML gradually via Apache Abdera. Thus, I should "serialize" my Java domain objects into the XML (feed), creating from the information in them values for the different tags and writing these tags into the output stream one by one, following the order defined by the XSD. III. NEEDED FUNCTIONALITYAt the moment, I have a serializer which is converting my domain objects into xml in the way described above, but soon it will need to support several types of schemas and it won't be easily maintainable (not to mention that it'd be very error prone). IV. POTENTIAL SOLUTIONSo, I want to make XML schema-agnostic serializer and to delegate the work for the creation of the values for the different xml elements to some dedicated builders or factories. The order by which they should be invoked though, should be defined by the order of the xml elements by the schema.And here is coming my quesiton with which I started:Is there a way/Java-based library by which I can retrieve the order of the XML elements by reading/loading its XSD (in advance)?V. IF THERE IS SUCH LIBRARY...Schematically, what the serializer need to do is:[*]load the types of the xml elements (tags) (with their restrictions of course) in the order they are defined in the XSD[*]iterate over the loaded types of the xml elements in the order they are loaded and [*]for each xml element type recognized, delegate the building the content for the corresponding element to an associated builder or factory. [*]having the value built by the builder/factory, the serializer just wrap it with the tag of the element and flush it into the output stream.Thanks in advance!
 
Back
Top