users@jaxb.java.net

Jaxb, problems without solutions ?

From: johann Sorel <sorel.johann_at_inbox.com>
Date: Fri, 1 Aug 2008 01:47:22 -0800

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