Re: [Simple-support] ElementUnion and xs:any
Brought to you by:
niallg
|
From: João M. G. <jm...@gm...> - 2012-07-11 10:23:30
|
Hi Simon,
Thanks for the reply! I guess I could code a Converter for the
container class, that way it should work. Question: does a registered
Converter take precedence over annotation-based serialization?
However, IMO, for a good XML-Java correspondence a fully qualified
element name should map 1-to-1 to a Java class. But Simple takes a
different (simpler! ;) ) approach. It gets the target class explicitly
from method calls for reading and inspection for writing, and I'd say
this design is great for performance. However flexible lookup, maybe
with an additional setup step (i.e. "element {http://foo/bar/}x should
be converted to class foo.bar.X"), would be extremely convenient for
the case we're targeting.
Cheers,
João
On Wed, Jul 11, 2012 at 9:40 AM, Simon Brodt <sim...@if...> wrote:
> Dear João,
>
> Would it be possible to use a ElementUnion,
>
> @ElementUnion({
> @Element(name="circle", type=Circle.class),
> @Element(name="square", type=Square.class)
> @Element(name="generic", type=GenericElement.class)
> })
>
> together with an Visitor
> (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#int
> ercept) that for the deserialization transforms non-mapped xml-tags to
> generic xml-tag with an attribute indicating the original name of the tag
> and transforms a generic xml-tag back to the original tag for the
> serialization?
>
> True, an additional attribute for @ElementUnion where you could specify that
> all unmapped tags should be interpreted as some type X (i.e.
> GenericElement.class) would be more convenient.
>
> Best regards
>
> Simon
>
> -----Ursprüngliche Nachricht-----
> Von: João M. Gonçalves [mailto:jm...@gm...]
> Gesendet: Dienstag, 10. Juli 2012 20:39
> An: sim...@li...
> Betreff: [Simple-support] ElementUnion and xs:any
>
> 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
>
> ----------------------------------------------------------------------------
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|