Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1029269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:31:09+00:00 2026-05-16T12:31:09+00:00

when serializing my resources on Jersey, I want to use namespaces in some cases.

  • 0

when serializing my resources on Jersey, I want to use namespaces in some cases.

Is there any way to customize the namespace prefixes on jersey?

Default:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order xmlns:ns2="http://www.w3.org/2005/Atom">
   <price>123</price>
   <ns2:link rel="duh" href="/abc/123"/>
   <ns2:link rel="abc" href="/def/234"/>
</order>

I want something like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order xmlns:atom="http://www.w3.org/2005/Atom">
   <price>123</price>
   <atom:link rel="duh" href="/abc/123"/>
   <atom:link rel="abc" href="/def/234"/>
</order>

Thanks,
Lucas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:31:09+00:00Added an answer on May 16, 2026 at 12:31 pm

    If you use the MOXy JAXB implementation you can control your prefixes using the @XmlSchema package level annotation:

    @javax.xml.bind.annotation.XmlSchema(  
        xmlns = {  
              @javax.xml.bind.annotation.XmlNs(prefix = "atom", namespaceURI = "http://www.w3.org/2005/Atom")  
                })  
        package org.example.domain;  
    

    To use MOXy JAXB you need to have a file named jaxb.properties in with your model classes with the following entry:

    javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
    

    For an example of using MOXy with Jersey see:

    • http://bdoughan.blogspot.com/2010/08/creating-restful-web-service-part-35.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When serializing, I would like to serialize an object only once, then any references
Duplicate: Serializing to JSON in jQuery It seems there's a JSON serializer/deserializer built into
When serializing/de-serializing certain classes I've come across the need to flag or mark certain
I'm serializing an object in a C# VS2003 / .Net 1.1 application. I need
I'm serializing class which contains DateTime property. public DateTime? Delivered { get; set; }
I'm serializing to XML my class where one of properties has type List<string>. public
I am serializing a class using simple-xml ( http://simple.sourceforge.net/ ) but when i try
I'm de/serializing an object like so: public class myClass : ISerializable { public List<OType>
Has anyone run into issues serializing components into a file and reading them back,
A project I'm working on requires serializing a data structure before shutting down and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.