Below are my answers to your questions:
What are the options for parsing? Can I implement / connect my own parser easily?
JAXB ( JSR-222 ), the implementation can be disconnected from many different types of input: InputStream
, InputSource',
Node ,
XMLStreamReader ,
XMLEventReader ,
File ,
Source`. If your XML representation matches any of them, then you are all set.
How about reality? Suppose I have a relaxed parser that is somewhat relaxed with respect to the scheme. Can I create a (invalid) Structure Object?
JAXB implementations require XML to be well-formed, but do not require it to be valid with respect to the XML schema. It is designed to handle a wide range of documents. If you want to provide "validity", you can install an XML schema (see JAXB and the Unmarshal Schema Validation ).
Does JAXB provide special tools for execution, for example. validation of objects? I would like to analyze the structure of "invalid" objects, the algorithm to fix it, and then check (in Java).
You can use the javax.xml.validation
APIs to validate against the object model. Full example:
Does JAXB provide other ways to do things on objects (e.g. visitor pattern).
JAXB models are POJOs, so you can design them as you wish. You may be interested in the following classes:
What about the amount of memory? Is an object representation (excluding parsing) acceptable for 10-100 MB XML files?
Yes, JAXB can be used to process documents of this size. If you are worried about size, you can use the XMLStreamReader
to parse the XML file, and then disconnect the objects from the XMLStreamReader
in pieces.