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 6759741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:59:10+00:00 2026-05-26T13:59:10+00:00

Image I have an element like this <someElement a= b= number=1 scale=meters><child/></someElement> scale and

  • 0

Image I have an element like this <someElement a="" b="" number="1" scale="meters"><child/></someElement>

scale and number always appear together but they are not defined in one exclusive element.

When unmarshalling the someElement element to a SomeElement java instance I want a single member in the SomeElement class to represent number and scale.

At the moment both number and scale are attributes and then the afterUnmarshall() method is used for calculating one number.

Is there a way to do this without having the two member fields size and scale? Maybe with a XmlAdapter? How would I use this in this case?

  • 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-26T13:59:10+00:00Added an answer on May 26, 2026 at 1:59 pm

    Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.

    MOXy offers the @XmlTransformation extension that allows you to represent a Java field/property as several XML nodes.

    For More Information

    • http://blog.bdoughan.com/2010/08/xmltransformation-going-beyond.html

    UPDATE

    Alternatively you could use an XmlAdapter for this use case. The adapter will we responsible for converting the single type representing number and scale (represented as FOO below) to a type with separate properties for number and scale. You will still need to use the MOXy implementation to leverage the @XmlPath extension:

    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    public class SomeElement {
    
        @XmlAttribute
        private String a;
    
        @XmlAttribute
        private String b;
    
        @XmlJavaTypeAdapter(NumberAndScaleAdapter.class)
        @XmlPath(".")
        private FOO numberAndScale;
    
        private Child child;
    
    }
    

    For More Information

    • http://blog.bdoughan.com/search/label/XmlAdapter
    • http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image tag enclosed in an anchor element like this: <a href='$image'><img
I have a Zend_Form with file element like this: ->addElement('file', 'image', array( 'required' =>
I have an anchor element like this: <a href=/link-to-image/ rel=attachment wp-att-7076><img src=/uploads/img.jpg alt= title=
I have this structure (from markItUp plugin): It's image button with CSS a:hover element.
I have a messy html that looks like this: <div id=:0.page.0 class=page-element style=width: 1620px;>
I have a HTML string ( not DOM element ) like : <p>This is
I have an array with each element is a string like this: $items[0] =
I have a previously generated XML like this: <newsletter> <header> </magazine> </image> <strap/> </header>
To have a gradient background on an element I do something like this: .css('filter','progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#FFFFFF\',
I have a set of code like this: $('.rightMainP').hover(function() { $('#rightMain img:first-child').attr('src', '../Images/whiteSidewaysNub.png') },

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.