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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:04:43+00:00 2026-05-30T15:04:43+00:00

I want to generate java code from xsd using JAXB 2.1 XJC. I have

  • 0

I want to generate java code from xsd using JAXB 2.1 XJC. I have an xsd schema provided and I can’t change it. I would like to use xjc:simple mode while generating java classes from xml schema.

In the xsd there are elements:

<xs:any namespace="##other" processContents="lax"/>

As it is stated here: http://jaxb.java.net/guide/Mapping_of__xs_any___.html I expected that these elements will be binded to:

@XmlAnyElement(lax=true)
public Object any;

but when I use simple binding mode xjc:simple I have:

@XmlAnyElement
protected Element any;

I was trying to find a workaround, but everywhere it’s said that xs:any is handled with no configuration. The only way to have xs:any element as java.lang.Object is to drop xjc:simple or change processContents to “strict” in xsd. None of these options are acceptable right now for me as I can’t change xml schema and I have some legacy code that depends on java classes generated with xjc:simple mode but now I need to use xs:any element and I would like to avoid using org.w3c.dom.Element objects.

Any help would be very appreciated. Thanks.

  • 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-30T15:04:44+00:00Added an answer on May 30, 2026 at 3:04 pm

    You can use the Wildcard plugin from JAXB2 Basics. This allows you to customize lax/skip/strict wildcard binding modes:

    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:wildcard="http://jaxb2-commons.dev.java.net/basic/wildcard"
        jaxb:version="2.1"
        jaxb:extensionBindingPrefixes="wildcard">
    
    ...
    
        <xs:complexType name="issueJIIB10Type" mixed="true">
            <xs:annotation>
                <xs:appinfo>
                    <wildcard:lax/>
                </xs:appinfo>
            </xs:annotation>
            <xs:complexContent mixed="true">
                <xs:extension base="xs:anyType"/>
            </xs:complexContent>
        </xs:complexType> 
    
    ...
    
    </xs:schema>
    

    You don’t have to change the schema for this, you can use this customization via binding files.

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

Sidebar

Related Questions

I want to call a C subroutine from Java. I'm using JNI. I have
I want to use JBoss tools in Eclipse to generate java code from DDL.
I want to generate random colours which can be attractive in pie charts.I have
I have a schema (xsd), and I want to create xml files that conform
I want to make a java swing application from where i can generated xml
I'm a Java/Eclipse noob and I want to generate class diagrams from my source.
I want to generate some html code for the jsf page I have (I
I am using jax-ws's wsimport to generate java classes from WSDLs. I am using
I want to generate a thumbnail preview of videos in Java. I'm mostly JMF
Let's say I have a class of 30 students and want generate every possible

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.