users@jaxb.java.net

Re: Jaxb, problems without solutions ?

From: Malachi de Ælfweald <malachid_at_gmail.com>
Date: Fri, 1 Aug 2008 07:35:00 -0700

Here's an example of what I do for versioning (I realize it may not work for
you):

http://code.google.com/p/ambrosia/source/browse/trunk/src/main/resources/org/eoti/spec/mimirdb/mimirdb-1.0.xsd

1. I have the version in the xsd name so they can live side-by-side
(mimirdb-1.0.xsd)
2. targetNamespace contains the version ("http://eoti.org/spec/mimirdb/1.0")
3. jaxb:package binding includes the version ("org.eoti.spec.mimirdb.v1")
4. If I need to convert between two versions of a spec, you can load both
and do it


Mal

On Fri, Aug 1, 2008 at 2:47 AM, johann Sorel <sorel.johann_at_inbox.com> wrote:

> Hello
>
> I have several problems with no answer. If anyone have a trick to handle
> thoses it would be nice.
>
>
> 1- XML Specification version ---------------------------------
>
> I need to output my objects in 2 different xml specification version, here
> is an exemple :
>
> OGC Style Layer Descripter v1.0
> <StyledLayerDescriptor version="1.0" ...>
> <Name>SLD Name</Name>
> <Title>SLD Title</Title>
> <Abstract>SLD Abstract</Abstract>
> ...
> </StyledLayerDescriptor>
>
> OGC Style Layer Descripter v1.1.0
> <StyledLayerDescriptor version="1.1.0" ...>
> <se:Name>SLD Name</se:Name>
> <se:Description>
> <se:Title>SLD Title</se:Title>
> <se:Abstract>SLD Abstract</se:Abstract>
> </se:Description>
> ...
> </StyledLayerDescriptor>
>
> You can see that in thoses 2 version some elements namespaces have changed.
> Since the namespace is hard coded in the annotation I'm stuck.
>
> I dont want to duplicate everything for several reasons (it's stupid, it's
> double the jar size, it's raise enourmusly the maintenance time, it bring
> nothing more and users get lost in the code)
>
> Anyone have a solution ?
>
>
>
> 2- Having XmlElement or XmlValue -------------------------------
>
> It is common to see in xml a plain text value or sub elements, here is an
> exemple :
>
> <se:AnchorPointX>456</se:AnchorPointX>
> or
> <se:AnchorPointX><ogc:literal>456</ogc:literal></se:AnchorPointX>
> (There are many other possibilities in my case but the annoying one is the
> plain xml value)
>
> Seens JaxB doesnt allow to have @XmlValue And @XmlElement at the same time
> in a class I'm stuck.
>
> Is there a trick to handle this ?
>
>
>
> 3- Using XML attribut for binding ------------------------------
>
> In some cases I have a list of elements with a special identification
> attribut.
>
> <Stroke>
> <SvgParameter name="stroke">#0000ff</SvgParameter>
> <SvgParameter name="stroke-width">2</SvgParameter>
> </Stroke>
>
> I would like to bind a svgparameter with a given name on a object field,
> something like this :
>
> @XmlElement(name = "SvgParameter", attribut="name",
> attributValue="stroke-width" )
> @XmlJavaTypeAdapter(ExpressionAdapter.class)
> private final Expression width;
>
> Unfortunatly this doesnt exist. any trick here ?
>
>
>
> Regards
>
> Johann Sorel
>
> ____________________________________________________________
> FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on
> your desktop!
> Check it out at http://www.inbox.com/marineaquarium
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>