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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:55:53+00:00 2026-05-25T05:55:53+00:00

The following schema should be generating two primitive int fields in a Value class,

  • 0

The following schema should be generating two primitive int fields in a Value class, but instead generates a primitive int for the element and java.lang.Integer for the attribute.

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.example.com/test" xmlns:test="http://www.example.com/test"
    elementFormDefault="qualified">

    <xsd:element name="values">
        <xsd:complexType>
            <xsd:sequence minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="test:value" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="value">
        <xsd:complexType>
            <xsd:sequence>
                <!-- Is generated as primitive int -->
                <xsd:element name="element" type="xsd:int" />
            </xsd:sequence>
            <!-- Is generated as java.lang.Integer -->
            <xsd:attribute name="attribute" type="xsd:int" />
        </xsd:complexType>
    </xsd:element>

</xsd:schema>

I’ve looked through the JAXB documentation for anything that says that attributes and elements may be generated differently and found nothing.

Can anyone explain this? Is there a fix to make the attribute generate as a primitive int?

  • 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-25T05:55:54+00:00Added an answer on May 25, 2026 at 5:55 am

    I’m not entirely sure this is the answer, but I had an epiphany while debugging my app.

    The default multiplicity for an element in an XML schema is 1..1 (required) where as the default multiplicity for an attribute is 0..1 (optional).

    1. So, since the element is required and a primitive in Java has a default value (most likely 0), it makes sense to generate an <xsd:element type="xsd:int" /> as a Java primitive.

    2. Since the attribute is optional there is a possibility that it may be nillable which would not be possible using a primitive. The java.lang.Integer is an Object and thus allowed to be null, so it makes sense to generate an <xsd:attribute type="xsd:int" /> as an java.lang.Integer.

    If you make an attribute be required (<xsd:attribute type="xsd:int" use="required" />), it will generate as a primitive int. I haven’t seen documentation by JAXB that explicitly says this, but that doesn’t mean it doesn’t exist; perhaps I just missed it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a table I have the following schema table1: playerID int primary key, nationalities
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
The following XSD should validate that the favorite_fruit element's name attribute should only contain
I have table with following fields: father_id child_id Both of them should point to
Consider the following database schema: create table UserGroup ( id int not null auto_increment,
Although the actual schema is a bit more complex, the following should be a
Suppose I have the following XML, how should I update my XSD schema (described
Having the following table schema: tablename( name varchar[100], age int, sex char[1] ) Having
Trying to map the following schema using the Entity Framework. A Customer can have
Given the following schema / data / output how would I format a SQL

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.