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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:40:56+00:00 2026-05-26T11:40:56+00:00

i use a xsd schema with an element datatype double like this: <xsd:element name=value

  • 0

i use a xsd schema with an element datatype double like this:

<xsd:element name="value" type="xsd:double"/>

I use the jaxB unmarschaller to create an java class with the appropriate object and attributes. The result looks like this:

protected double value;

Now, the xml data is able to send nullable value elements, but i am not in the position to fit the xsd schema to the datatype Double.class. Is it possible to overwrite the attribute in the java class?

  • 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-26T11:40:57+00:00Added an answer on May 26, 2026 at 11:40 am

    If you cannot modify the XML schema to make the value element nillable, then you could do the following with a JAXB external bindings file:

    External Bindings File (binding.xml)

    You could use an external bindings file like the following:

    <jaxb:bindings 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
        jaxb:extensionBindingPrefixes="xjc"
        version="2.1">
        <jaxb:bindings schemaLocation="double.xsd">
            <jaxb:bindings node="//xs:element[@name='value']">
                <jaxb:property>
                    <jaxb:baseType name="java.lang.Double"/>
                </jaxb:property>
          </jaxb:bindings>
       </jaxb:bindings>
    </jaxb:bindings>
    

    XML Schema – double.xsd

    The above bindings file applies to an XML Schema that looks like the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="Root">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="value" type="xs:double"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:schema>
    

    XJC Call

    xjc -d out -b binding.xml double.xsd
    

    Generated Class

    package generated;
    
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;
    
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {"value"})
    @XmlRootElement(name = "Root")
    public class Root {
    
        @XmlElement(required = true, type = Double.class)
        protected Double value;
    
        public Double getValue() {
            return value;
        }
    
        public void setValue(Double value) {
            this.value = value;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given an XML layout like this, I'm trying to create a XSD schema to
I have an XML schema: <xsd:element name=Person> <xsd:complexType> <xsd:sequence> <xsd:element name=name type=xsd:string /> <xsd:element
I have this schema and i'm using JAXB to generate java stub files. <?xml
I have problem with types in my schema when trying to use xsd:any element
We have a netbeans project that has an xsd that we use to create
I'm trying to use the XML::LibXML::Schema to validate a xml file against a xsd.
In my schema I have some types that simply extend a simple XSD type
I have an existing XML schema that contains a type that I would like
I saw an xml schema ( EPP ) whitch used xsd:choice with an element
I have the following java class with the JAXB @XMLRootElement annotation @XmlRootElement(name=ClientData) public class

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.