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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:05:45+00:00 2026-05-29T06:05:45+00:00

I made some classes using xjc. public class MyType { @XmlElementRefs({ @XmlElementRef(name = MyInnerType,

  • 0

I made some classes using xjc.

    public class MyType {

    @XmlElementRefs({
        @XmlElementRef(name = "MyInnerType", type = JAXBElement.class, required = false),

    })
    @XmlMixed
    protected List<Serializable> content;

    public List<Serializable> getContent() {
        if (content == null) {
            content = new ArrayList<Serializable>();
        }
        return this.content;
    }
}

But i cant add inner elements using

getContent().add(newItem);

because MyInnerType is not Serializable.
Why its not a List of Objects? How do i add inner elements?

  • 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-29T06:05:45+00:00Added an answer on May 29, 2026 at 6:05 am

    Please take a look here and here (one should for sure address your scenario).

    From 2nd link:

    <!-- schema fragment having  mixed content -->
    <xs:complexType name="letterBody" mixed="true">
    <xs:sequence>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="quantity" type="xs:positiveInteger"/>
        <xs:element name="productName" type="xs:string"/>
        <!-- etc. -->
    </xs:sequence>
    </xs:complexType>
    <xs:element name="letterBody" type="letterBody"/>
    
    
    // Schema-derived Java code: 
    // (Only annotations relevant to mixed content are shown below, 
    //  others are ommitted.)
    import java.math.BigInteger;
    public class ObjectFactory {
        // element instance factories
        JAXBElement<LetterBody> createLetterBody(LetterBody value);
        JAXBElement<String>     createLetterBodyName(String value);
        JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
        JAXBElement<String>     createLetterBodyProductName(String value);
      // type instance factory
        LetterBody> createLetterBody();
    }
    
    public class LetterBody {
        // Mixed content can contain instances of Element classes
        // Name, Quantity and ProductName. Text data is represented as
        // java.util.String for text.
        @XmlMixed 
        @XmlElementRefs({
                @XmlElementRef(name="productName", type=JAXBElement.class),
                @XmlElementRef(name="quantity", type=JAXBElement.class),
                @XmlElementRef(name="name", type=JAXBElement.class)})
        List getContent(){...}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made some unit tests (in test class). The tutorial I've read said that
I've made some graphs in my ASP.Net MVC application using the ASP.Net MSChart control.
If I look at some classes in the framework, using reflector, I can see
I read how this can be made to work using forward declarations. class A
I am using Liblinear in matlab to predict values, I have some classes and
I need to make some stream in and out classes using mmap() in Linux.
I have a DLL made in C#, this DLL contains some clases like Creator.
I made some changes to an existing application that was previously just straight HTML
I made some changes to an open source project without taking time to create
I made some code, for understanding the concept/basic of pointer: int a=1; int *b=&a;

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.