You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "KARR, DAVID" <dk...@att.com> on 2012/06/07 19:56:37 UTC
How to configure namespace prefixes in Jettison
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?
Re: How to configure namespace prefixes in Jettison
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 13/06/12 14:58, KARR, DAVID wrote:
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Wednesday, June 13, 2012 3:39 AM
>> To: users@cxf.apache.org
>> 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?
2.5.5, 2.6.2, 2.7.0.
I did not merge to 2.4.x, let me know please if you'd like 2.4.x updated too
Cheers, Sergey
>
>> 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:sberyozkin@gmail.com]
>>>>> Sent: Monday, June 11, 2012 5:29 AM
>>>>> To: users@cxf.apache.org
>>>>> 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
RE: How to configure namespace prefixes in Jettison
Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Wednesday, June 13, 2012 3:39 AM
> To: users@cxf.apache.org
> 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:sberyozkin@gmail.com]
> >>> Sent: Monday, June 11, 2012 5:29 AM
> >>> To: users@cxf.apache.org
> >>> 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
Re: How to configure namespace prefixes in Jettison
Posted by Sergey Beryozkin <sb...@gmail.com>.
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, 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:sberyozkin@gmail.com]
>>> Sent: Monday, June 11, 2012 5:29 AM
>>> To: users@cxf.apache.org
>>> 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
Re: How to configure namespace prefixes in Jettison
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi David
On 11/06/12 17:42, KARR, DAVID wrote:
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Monday, June 11, 2012 5:29 AM
>> To: users@cxf.apache.org
>> 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
RE: How to configure namespace prefixes in Jettison
Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Monday, June 11, 2012 5:29 AM
> To: users@cxf.apache.org
> 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.
Re: How to configure namespace prefixes in Jettison
Posted by Sergey Beryozkin <sb...@gmail.com>.
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
Cheers, Sergey
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com