users@jaxb.java.net

Re: Jaxb, problems without solutions ?

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Fri, 1 Aug 2008 12:10:09 +0200

Hi.

> I have several problems with no answer. If anyone have a trick to handle thoses it would be nice.

You may find https://ogc.dev.java.net project interesting.

> 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 ?

Not really. Either you stick to one version or use an XSLT to convert
between different versions.

> 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 ?

No, sorry.

Bye.
/lexi