[Simple-support] ElementUnion and xs:any
Brought to you by:
niallg
|
From: João M. G. <jm...@gm...> - 2012-07-10 18:39:31
|
Hi Niall, all, I started using SimpleXML recently in an open source project (https://github.com/societies/). We started out using JAXB but due to a number of problems of JAXB on Android are attempting a move to Simple. Today I came across two problems. The first one is regarding using Simple in environments with multiple ClassLoaders, such as an OSGi container. I didn't fully study the problem, will do so in the next few days since it is not a show stopper for us. I'll keep you posted. Regarding the second problem is the use of element union. We were using JAXB because we wanted to be XML-centric (schema) rather than Java-centric. Our data model for communication would be designed in pure XML so that it could (theoretically) be used in any language. Happens that we have "xs:any" in a few places. From what I've gathered from Simple documentation, this would map to have an Object field annotated with @ElementUnion. However, this places a dependency in the containing types to the contained types: @ElementUnion({ @Element(name="circle", type=Circle.class), @Element(name="square", type=Square.class) }) This is not acceptable for us as we want to keep the Java data model clean, consistent with the schema. If the dependency is not in the schema it should not be in the Java version either. For the same reason the explicit indication of the class as an attribute (<any class="foo.bar.X">) is also not a good solution. One good solution for us would be supporting the (de)serialization of a non mapped class to/from a generic XML element, such as org.w3c.dom.Element, as supported by JAXB. Any thoughts? I am available to contribute to Simple regarding this issue if you want our help. Cheers, João |