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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:43:18+00:00 2026-05-28T00:43:18+00:00

Hi stackoverflow world, I want to specify in a XSD that a specific element

  • 0

Hi stackoverflow world,

I want to specify in a XSD that a specific element can be used as a XmlRootElement by JAXB.

I know how to add the annotation to the generated class: what I want to do is to specify that a element can be generated as a root element before the code generation.

I use external JAXB customizations (.xjb files).
The purpose is here to not modifying the schemas (as they are defining standards).

Anybody knows how do that?
Thanks!

NJ

  • 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-28T00:43:18+00:00Added an answer on May 28, 2026 at 12:43 am

    Problem solved.

    The JAXB plugin Annotate http://confluence.highsource.org/display/J2B/Annotate+Plugin do the job.

    Add the following fragment in your jaxb binding file (external binding, i.e. a .xjb file):

    <jaxb:bindings schemaLocation="csw/2.0.2/CSW-discovery.xsd" node="/xs:schema">
      <jaxb:bindings node="xs:complexType[@name='GetRecordsType']">
        <annox:annotate>
      <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
                     name="GetRecordsType" />
    </annox:annotate>
      </jaxb:bindings>
    </jaxb:bindings>
    

    Do not forget to declare the namespaces:

    <jaxb:bindings 
      xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
      xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xmlns:annox="http://annox.dev.java.net"
      xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
      jaxb:extensionBindingPrefixes="xjc annox" version="2.1">
     ...
     </jaxb:bindings>
    

    And use a ANT or MAVEN task http://confluence.highsource.org/display/J2B/User+Guide to proceed the generation of the sources.

    I still search how to specify manually (without an xjc task with ant or maven) the JAXB extensions but it works now. (I have my own ANT script what’s why I search to manually call XJC).

    The JAXB extension mechanism is very convenient, have a look to JAXB2 Basics:
    http://confluence.highsource.org/display/J2B/Home

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

Sidebar

Related Questions

I'm looking content management system that would have features similar to stackoverflow: Users can
I'm new to world of .NET programming and I want to know about websites
stackoverflow world! I have h:panelGrid, containing some elements. I want to trigger an action
I don't want to add another username and ID to the world, so I
Possible Duplicates: How would I implement stackoverflow’s hovering dialogs? i want a small box
I would like to make a nightly cron job that fetches my stackoverflow page
I know this question has been asked a million of times here at stackoverflow,
I have an application that deals with clients from all over the world, and,
Is there a function in Dojo that lets you specify URL parameters that I
Hello stackoverflow world, I am stuck on a little problem with Java Plugin Framework

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.