users@jersey.java.net

Jersey and schema prefix

From: Pierre Radermecker <pradermecker_at_yahoo.ca>
Date: Tue, 24 Aug 2010 07:57:13 -0700 (PDT)

Hi,

I have been searching for this finding bits of solutions but I don't seem to be
able to make it work somehow.

By default Jaxb will generate a schema prefix such as "ns2". Jaxb does not seem
to care at all about the prefix of my package-info file:

@XmlSchema(
        namespace = "http://myurl/ns/enterprise",
        xmlns = {_at_XmlNs(prefix = "ent", namespaceURI =
"http://myurl/ns/enterprise")},

       elementFormDefault= XmlNsForm.UNQUALIFIED
)

Is this a kind of bug ? Apparently there is a way to set a custom prefix using
com.sun.xml.bind.marshaller.NamespacePrefixMapper but I have no idea how to do
that inside Jersey (with Guice).

I would not mind removing any kind of prefix completely. I can easily manage
this by removing the xmlns declaration above but as soon as I create an ancestor
to a resource, if the ancestor is not in the same package and if the ancestor
contains some @XmlElement declaration I have got a prefix generation ... I find
it a bit awkward to define "getters" in the subclass to avoid @XmlElement
declaration in the base class.

@XmlRootElement()
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public final class Enterprise extends AbstractEntity {
       ....
}


public class AbstractEntity {
    @XmlElement
    private String createdBy;
}


Thanks for your help.

- Pierre