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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:38:04+00:00 2026-05-22T00:38:04+00:00

I have a schema defined as this: <complexType name="x"> <sequence> <element name="year" type="date"/> <choice>

  • 0

I have a schema defined as this:

<complexType name="x">
    <sequence>
        <element name="year" type="date"/>
            <choice>
                <element name="comuneNascita" type="string" nillable="true"/>
                <element name="statoNascita" type="string" nillable="true"/>
             </choice>
    </sequence>
</complexType>

When I try to marshall the class generated with xjc ( with xjc:simple option ) and I get this result:

[...]
<statoNascita xsi:nil="true"/>
<comuneNascita>xxx</comuneNascita>
[...]

Removing nillable="true" solve this problem but then I have to specify a valid element ( not nilled ).

Any workaround?

  • 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-22T00:38:04+00:00Added an answer on May 22, 2026 at 12:38 am

    You can avoid your problem by having a property annotated as follows:

    @XmlElements({
       @XmlElement(name="comuneNascita", type=String.class),
       @XmlElement(name="statoNascita", type=String.class),
    })
    

    You can get XJC to generate a property annotated as above using a JAXB bindings file:

    <?xml version="1.0" encoding="UTF-8"?>
    <bindings xmlns="http://java.sun.com/xml/ns/jaxb"
              version="2.1">
        <globalBindings choiceContentProperty="true"/>
    </bindings> 
    

    For More Information

    • http://bdoughan.blogspot.com/2011/04/xml-schema-to-java-xsd-choice.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this schema: <xs:complexType name=foo> <xs:sequence> <xs:element name=oneBar type=xs:string minOccurs=0/> <xs:element name=twoBar type=xs:string
Suppose I have some schema: <xsd:schema ...> <xsd:element name=foo> <xsd:complexType> <xsd:sequence> <xsd:element name=fooElement type=xs:string
I have an XML document snippet that matches this XSD: <xs:complexType name=QuestionType> <xs:sequence> <xs:element
I have an XML schema, where element Calling1 is defined like this: <xsd:element name=Calling1
I have a schema containing (for example)... <xsd:complexType name=mytype> <xsd:sequence> <xsd:any maxOccurs=unbounded processContents=skip/> </xsd:sequence>
I have given the local name of an element or attribute and the schema
I have defined this entity in schema.yml Jobsearch: tableName: jobsearch columns: seeker_id: primary: true
I have a custom XML schema defined for page display that puts elements on
I have several existing XML schema files with a defined data model. I would
Assuming you have two lists defined in an xml schema, call them A 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.