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

The Archive Base Latest Questions

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

I use JAXB 2.1 to generate Java classes from several XSD files that I

  • 0

I use JAXB 2.1 to generate Java classes from several XSD files that I cannot modify (coming from a WSDL file actually), and I have a problem related to complex type restriction.
On of the restrictions modifies the occurence configuration from minOccurs="0" maxOccurs="unbounded" to minOccurs="0" maxOccurs="0". Thus this field is not needed anymore in the restricted type. But actually JAXB generates the restricted class with a [0..1] cardinality instead of 0.

By the way the generation is tuned with <xjc:treatRestrictionLikeNewType /> so that a XSD restriction is not mapped to a Java class inheritance.

Here is an example:

Here is the way a field is defined in a complex type A:


<element name="qualifier" type="CR" maxOccurs="unbounded" minOccurs="0"/>

Here is the way the same field is restricted in another complex type B that restricts A:


<element name="qualifier" type="CR" minOccurs="0" maxOccurs="0"/>

In the A generated class I have:


@XmlElement(name = "qualifier")
protected List<CR> qualifiers;

And in the B generated class I have:


protected CR qualifiers;

With my poor understanding of JAXB the absence of the XmlElement annotation tells JAXB not to marshall/unmarshall this field. Am I wrong?
If I am right is there a way to tell JAXB not to generate the qualifiers field at all?
This would be in my opinion a much better generation as it respects the constraints.

Any idea, thougths on the topic?

Thanks!!

  • 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-15T10:26:54+00:00Added an answer on May 15, 2026 at 10:26 am

    If the type is not needed then alone minOccurs=”0″ should be enough, no ? Looks like you are trying to define an element that may not be included in the document – that does not make sense, although it’s valid.

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

Sidebar

Related Questions

I can use this maven plugin maven-jaxb-plugin to generate Java Classes from XSD file.
I use JAXB to generate Java classes from XML schema. Now I want to
I use maven-jaxb2-plugin to generate jaxb annotated classes from xsd. I have many xsd
On my current project we generate JAXB beans from an XSD file. We need
I want to generate a xsd file dynamically, I don't want to use jaxb
I want to generate java code from xsd using JAXB 2.1 XJC. I have
Using JAXB in Java it is easy to generate from a xml schema file
I Use XJC tool to generate Java classes for my XSD schema. When I
I have a XSD file, from which I want to generate C# and Java
I am trying to use the Jaxb classes generator in eclipse to generate 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.