users@jersey.java.net

JAXB prefix Mapper

From: guilhem legal <guilhem.legal_at_geomatys.fr>
Date: Tue, 05 Feb 2008 12:47:48 +0100

hi!

I'm using jersey to return xml using JAXB, I would know if it possible
to specify a NamespacePrefixMapper to jersey.

I explain :
                - if i use jersey to build my xml like this :

                Object obj = .....;
                return Response.ok(obj, "text/xml").build();

                my xml looks like that :
               
                <ns1:Object>
                         <ns1:property1/>
                         <ns2:property2/>
                   ............................

             - So i build my xml and return a string :
            
             JAXBContext jbcontext =
JAXBContext.newInstance("net.seagis.sos");
             marshaller = jbcontext.createMarshaller();
             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
             
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new
NamespacePrefixMapperImpl());
       
             Object obj = .....;
             StringWriter sw = new StringWriter();
             marshaller.marshal(Object, sw);
       
              return Response.ok(sw.toString(), "text/xml").build();

             and my xml looks like that:
            
             <sos:Object>
                      <sos:property1>
                      <gml:property2>
                      .............................

So my question is how to pass a namespacePrefixMapper to jersey?

Guilhem Legal