> -----Original Message----- > From: Sergey Beryozkin [mailto:[email protected]] > Sent: Wednesday, June 13, 2012 3:39 AM > To: [email protected] > Subject: Re: How to configure namespace prefixes in Jettison > > I updated JSONProvider to avoid auto-allocating prefixes on the output, > given that the namespace map is optional now, so it's better to let > JAXB > choose the default prefixes. This can be customized as usual using the > namespace map, and now, using the XmlNs package annotations
Thanks. Do you know what release(s) that will be included in? > thanks, Sergey > On 12/06/12 17:24, Sergey Beryozkin wrote: > > Hi David > > On 11/06/12 17:42, KARR, DAVID wrote: > >>> -----Original Message----- > >>> From: Sergey Beryozkin [mailto:[email protected]] > >>> Sent: Monday, June 11, 2012 5:29 AM > >>> To: [email protected] > >>> Cc: KARR, DAVID > >>> Subject: Re: How to configure namespace prefixes in Jettison > >>> > >>> Hi David > >>> On 07/06/12 18:56, KARR, DAVID wrote: > >>>> I've seen various FAQs and examples about configuring the > namespace > >>> prefixes used in Jettison output. What I've tried hasn't made any > >>> difference. > >>>> > >>>> I have a "package-info.java" that looks like this: > >>>> -------------- > >>>> @XmlSchema(namespace = > >>> "http://www.example.com/schema/app/SomeThing/v1.0", > >>>> elementFormDefault = XmlNsForm.QUALIFIED, > >>>> xmlns = { @XmlNs(prefix = "os", namespaceURI = > >>> "http://www.example.com/schema/app/SomeThing/v1.0"), > >>>> @XmlNs(prefix = "xs", namespaceURI = > >>> "http://www.w3.org/2001/XMLSchema"), > >>>> @XmlNs(prefix = "xsi", namespaceURI = > >>> "http://www.w3.org/2001/XMLSchema-instance")}) > >>>> // Use either FIELD or PUBLIC_MEMBER. If you change it, you have > to > >>> move the annotations. > >>>> @XmlAccessorType(XmlAccessType.FIELD) > >>>> package com.example.app.domain; > >>>> > >>>> import javax.xml.bind.annotation.XmlAccessType; > >>>> import javax.xml.bind.annotation.XmlAccessorType; > >>>> import javax.xml.bind.annotation.XmlNs; > >>>> import javax.xml.bind.annotation.XmlNsForm; > >>>> import javax.xml.bind.annotation.XmlSchema; > >>>> -------------- > >>>> > >>>> When I make the call, however, my output uses a "ns1" namespace > >>> prefix (instead of the "os" that I was trying to set it to). Am I > >>> missing an association with the package? > >>> > >>> I wonder if this blog can explain why the above declarations are > >>> ignored ? > >>> http://hwellmann.blogspot.ie/2011/03/jaxb-marshalling-with-custom- > >>> namespace.html > >> > >> I tried implementing the alleged fix using solution 2, but it had no > >> effect. I verified that the 2.2.2 implementation was put into the > jar. > >> > >> I could spend some time tracing through some code in the debugger if > I > >> had some clues about what to look for. > > > > JSONProvider attempts to set up a namespace map internally and > > unfortunately it overrides the package level information. > > At this stage, given that you also need it working in a non-Spring > case, > > the workaround is to extend JSONProvider and in the custom provider > > constructor call super.setNamespaceMap. I'll need to check a bit more > > how easy it is to avoid auto-populating the namespace map. > > > > Cheers, Sergey > > > > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com
