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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:02:22+00:00 2026-05-21T16:02:22+00:00

Is it possible, using JAXB, probably using MOXy, to flatten a base class into

  • 0

Is it possible, using JAXB, probably using MOXy, to “flatten” a base class into its subclass in marshalling, so that the Java inheritance is not visible in the XML? We have many hand-created classes that are based 1-to-1 on generated classes – the base class has no value in the XML.

If it isn’t obvious, we’re using the schemagen feature – starting with the Java, creating a schema.

  • 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-21T16:02:23+00:00Added an answer on May 21, 2026 at 4:02 pm

    You can mark the base class with @XmlTransient.

    @XmlTransient
    public class Root {
    }
    

    This will cause the Child class to ignore the inheritance (WRT JAXB):

    public class Child extends Root {
    }
    

    For other examples see:

    • How can I ignore a superclass?

    Follow Up Issue

    The issue you posted on the forum is a bug. You can workaround it using a binding file like the following:

    binding-a.xml

    In the binding file specify a type name for the transient class. This type will not appear in the generated XML schema:

    <?xml version="1.0" encoding="UTF-8"?>
    <xml-bindings
        xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
        package-name="example.a">
        <java-types>
            <java-type name="MyOwnGrandpa" xml-transient="true">
                <xml-type name="MyOwnGrandpa2"/>
            </java-type>
        </java-types>
    </xml-bindings>
    

    example.a.MyOwnGrandpa

    package example.a;
    
    public class MyOwnGrandpa {
    
    }
    

    example.b.MyOwnGrandpa

    package example.b;
    
    public class MyOwnGrandpa extends example.a.MyOwnGrandpa {
    
    }
    

    example.Demo

    package example;
    
    import java.io.File;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.Map;
    
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.SchemaOutputResolver;
    import javax.xml.transform.Result;
    import javax.xml.transform.stream.StreamResult;
    
    import org.eclipse.persistence.jaxb.JAXBContextFactory;
    
    import example.b.MyOwnGrandpa;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            Map<String, Object> properties = new HashMap<String, Object>(1);
            properties.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY, new File("src/exanmple/a/binding-a.xml"));
            JAXBContext jc = JAXBContext.newInstance(new Class[] {MyOwnGrandpa.class} , properties);
            jc.generateSchema(new MySOR());
        }
    
        private static class MySOR extends SchemaOutputResolver {
    
            @Override
            public Result createOutput(String arg0, String arg1) throws IOException {
                StreamResult result = new StreamResult(System.out);
                result.setSystemId(arg1);
                return result;
            }
        }
    
    }
    

    Generated Schema

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <xsd:complexType name="myOwnGrandpa"/>
    </xsd:schema>
    

    UPDATE

    This issue is also being discussed on the EclipseLink Forum:

    • http://www.eclipse.org/forums/index.php?t=msg&th=208228&start=0&S=1ec5df3961f963fbc272ab4d94c9c70e
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know its probably possible, but is it practical and doable to try and
I know its probably possible, but is it practical and doable to try and
I'm trying to build a Chrome browser extension, that should enhance the way the
This is beyond both making sense and my control. That being said here is
I am writing a query to fetch results for all the values in a
I have several USB mass storage flash drives connected to a Ubuntu Linux computer
I am trying to load a html page through UIWebview.I need to disable all
I'm trying to write test harness for part of my Android mapping application. I
My question is about memory use and objects in actionscript 2. If I have

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.