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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:54:31+00:00 2026-05-26T04:54:31+00:00

I’m current working on a Java code that is using JaxB to handle reading/writing

  • 0

I’m current working on a Java code that is using JaxB to handle reading/writing of xml information. It populates a Java class which is used throughout the program. At certain points, the class is marshalled and written back into xml. I’m not having problems with this, and things are functioning as expected.

What I am curious about is if there is a way to alter the format of how JaxB writes out floating point numbers. For instance, part of the xml schema I am using contains the following excerpt:

.
.
<xs:element name="myObfuscatedValue">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:double">
        <xs:attrbute name="myObfuscatedValue__comment" type="comment" use="optional" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>
.
.

So when I unmarshall it, ‘myObfuscatedValue’ basically comes in as a Double. I then have a wrapper class around the JaxB generated classes that allows the user to access/modify the variables via standard setters/getters. Marshalling back works fine as well.

What I ALSO want to do is have JaxB write the double out in a specific number format (something similar to a DecimalFormat like “0.0000E00” . Is this possible to do easily? I have been bounced around to several different resources on how to do this, but I admit that my knowledge of xml/schemas/JaxB is not up to date. Is there a way to alter the xjc call to do this? If possible, I want to avoid changing the schema file if possible (it’s used by multiple codes in different languages, and I’d have to understand if changing it would break any of those codes first).

Any help, insight or suggestions on this matter would be greatly appreciated.

  • 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-26T04:54:32+00:00Added an answer on May 26, 2026 at 4:54 am

    You can use an XmlAdapter to customize how a value is represented in XML. Below is an example demonstrating how to use an XmlAdapter if you are generating an object model from an XmlSchema:

    • Using JAXB generated class for an element that requires an integer with a pattern
    • http://blog.bdoughan.com/2011/08/xml-schema-to-java-generating.html

    Here is another example using XmlAdapter when you start from Java classes:

    • http://blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... 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.