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

  • SEARCH
  • Home
  • 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 8498973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:32:46+00:00 2026-06-11T00:32:46+00:00

An instance of my JAXB Object model contains an element that I want output

  • 0

An instance of my JAXB Object model contains an element that I want output when I generate Xml for the instance but not when I generate json

i.e I want

<release-group>
<type>Album</type>
<title>Fred</title>
</release-group>

and

"release-group" : {
         "title" : "fred",
       },

but have

"release-group" : {
         "type" : "Album",
         "title" : "fred"
      },         

Can I do this using the oxml.xml mapping file

This answer shows how I can do it for attributes using the transient keyword, Can I get MOXy to not output an attribute when generating json? but I cannot get that to work for an element.

  • 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-06-11T00:32:48+00:00Added an answer on June 11, 2026 at 12:32 am

    Sorry problem solved, a bit of confusion on my part.

    The example I gave above didn’t actually match the true situation accurately, type was actually output as an attribute for Xml, but use of transient didnt work because it had been renamed in the JAXB

    @XmlAttribute(name = "target-type", required = true)
    @XmlSchemaType(name = "anyURI")
    protected String targetType;
    

    So adding

     <java-type name="ReleaseGroup">
                <java-attributes>
                    <xml-transient java-attribute="targetType"/>
                </java-attributes>
            </java-type>
    

    worked, previously I was incorrectly doing

     <java-type name="ReleaseGroup">
                <java-attributes>
                    <xml-transient java-attribute="target-type"/>
                </java-attributes>
            </java-type>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An instance of my JAXB Object model contains an attribute that I want output
I have to generate a xml element that can have as value any primitive
I am using JAXB 2.0 JDK 6 in order to unmarshall an XML instance
I want to unmarshall the following XML structure using JAXB: <orCondition> <andCondition> <andCondition> <simpleCondition
Using JAXB (2) is it possible to ensure that null values are not marshalled
I'm trying to use JAXB to unmarshall some XML, but I'm getting an Unable
I need to unmarshall an XML that has namespaces for the attributes, for instance
For instance, (/=[^>]/, '═') I'd like to keep that match, but only replace the
I have a Java application that I want to save the data in XML
Am trying to marshall a class that contains a List of Interface type. JAXB

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.