users@jersey.java.net

Re: [Jersey] Jersey and schema prefix

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 25 Aug 2010 11:16:54 +0200

On Aug 24, 2010, at 4:57 PM, Pierre Radermecker wrote:

> 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 do not know about the JAXB specifics in this case (as Tatu suggests
you might want to email the jaxb forum). For the namespace prefix
mapper see here:

   https://jaxb.dev.java.net/nonav/2.2.1/docs/
vendorProperties.html#prefixmapper

it is a property you set on the Marshaller.

For JAXB integration with JAX-RS you can define a ContextResolver
<Marshaller> implementation. There some basic info in the following
about ContextResolver (needs to be expanded):

https://jersey.dev.java.net/nonav/documentation/1.4-SNAPSHOT/user-guide.html
#jaxb

Paul.