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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:31:46+00:00 2026-06-04T12:31:46+00:00

I’m trying to generate Java classes from several specific XSD’s with xjc . Those

  • 0

I’m trying to generate Java classes from several specific XSD’s with xjc. Those schemas have some definitions in common, so they import a number of common XSD’s. In particular, they can include from zero to all of the common XSD’s.

I’d like to generate all classes from an specific XSD to a specific package, but keeping the generated classes for the common schemas in a common package, so they don’t get repeated for each specific schema in the source tree.

I’ve learnt that custom bindings can be used to specify packages on a per-schema basis, with for instance:

<jxb:bindings schemaLocation="common1.xsd" node="/xsd:schema">
    <jxb:schemaBindings>
        <jxb:package name="mypackage.commonclasses"/>
    </jxb:schemaBindings>
</jxb:bindings>

I’ve got the following structure:

schemas
| - common
| | - common1.xsd --> XSD with common types #1
| | - ...
| | - commonN.xsd --> XSD with common types #N
| | - commonBindings.xjb --> Defines package "mypackage.commons" for common*.xsd
| - specific1
| | - specific1.xsd --> Includes ../common/common{1-N}.xsd
| | - specific1.xjb --> Defines package "mypackage.specific1" for specific1.xsd
| - specificN
| | - specificN.xsd --> Includes only ../common/common1.xsd
| | - specificN.xjb --> Defines package "mypackage.specificN" for specificN.xsd

It all works fine with:

xjc -b schemas/specific1
    -b schemas/common 
    schemas/specific1/specific1.xsd

It generates the classes for specific1.xsd in mypackage.specific1 and the common classes in mypackage.commons. But when I try to generate the classes for specificN, xjc throws the following error:

[ERROR] "file:/drive/dir/schemas/common/common1.xsd" is not a part of
 this compilation. Is this a mistake for "/drive/dir/schemas/common/commonBindings.xjb"?
  line 2 of file:/drive/dir/schemas/common/commonBindings.xjb

I get this error repeated for every common XSD not imported in any specific xsd.

Is there any way I can make xjc ignore the bindings in commonBindings.xjb that aren’t used in the XSD I’m generating the classes for?

Or, am I aiming in the wrong direction by using this approach, and should be, for instance, using annotations in the specific xsd? I’d like to avoid modifying the schemas if possible.

  • 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-06-04T12:31:47+00:00Added an answer on June 4, 2026 at 12:31 pm

    I think that what you need is to use the JAXB episode. See this SO post, take a look at the answer @BlaiseDoughan provided.

    In your case, run xjc first, using your custom binding file for package name customization, against all the XSDs that are common, to generate an episode file and your common Java classes.

    Then use xjc again, with the other XSDs you want, by referencing the episode file from the first run.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which 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.