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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:46:14+00:00 2026-05-27T22:46:14+00:00

Here is my problem: I’m working on a project to migrate from Castor to

  • 0

Here is my problem:

I’m working on a project to migrate from Castor to JaxB. I am very new to JaxB and facing a problem which boggles my mind and yet, may be quite simple to solve. Here is a simple example :

class Data
{
    private Item item;
}

I have Data containing one Item. Here is how the output XML file (which I cannot change) looks like:

<Data>
    <Items>
        <Item>
        <Item>
    <Items>
<Data>

Even though Data contains only one Item, it should be presented in the output XML as an element in Items. The thing is, I do not want JaxB to generate a class or property for Items, only Data and Item.

How should my schema look like? Is there any way to specify in the schema that the specified item is stored in a node which has no class representation? Something which in my logic could look like that:

  <xs:element name="Data">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Items"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Items"> <!-- Do not generate plz -->
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Item" minOccurs="1" maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  • 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-27T22:46:15+00:00Added an answer on May 27, 2026 at 10:46 pm

    Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.

    For the following fragment, there isn’t a way to generate the classes in that way, because the standard JAXB APIs don’t provide path based mapping.

      <xs:element name="Items"> <!-- Do not generate plz -->
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="Item" minOccurs="1" maxOccurs="1"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    

    However, starting from Java classes you could use MOXy’s @XmlPath extension to map this use case:

    import org.eclipse.persistence.annotations.oxm.XmlPath;
    
    class Data
    {
        @XmlPath("Items/Item")
        private Item item;
    }
    

    For More Information

    • http://blog.bdoughan.com/2010/07/xpath-based-mapping.html
    • http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem here with an MSI deployment that I'm working on (using
I'm facing a problem here, with HttpListener. When a request of the form http://user:password@example.com/
PROBLEM: Here's the code: import matplotlib.pyplot as plt plt.bar([1,2],[5,4]) plt.title('this is a very long
The problem here is pretty self-evident from the resulting JSON array at the bottom.
Here's the problem: In C# I'm getting information from a legacy ACCESS database. .NET
Odd problem here. Working with an existing system that uses TinyMCE as it's text
Unusual problem here: I have an app that uses a text file which contains
i am new to jquery, i am working on a web page which needs
I've got problem here which I couldn't solve by myself. Everything was okay before,
i am having a small problem here. The table which dbml (LinqToSql designer) is

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.