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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:22:46+00:00 2026-06-13T17:22:46+00:00

I use JAXB 2.2.7 to get data from my XML files, the problem is

  • 0

I use JAXB 2.2.7 to get data from my XML files, the problem is I need to check if there are some unexpected element in my XML files but JAXB don’t care and work perfectly without any error.

Example :

    <classe> 
  <detail>
        <knowElementFromXSD>value</knowElementFromXSD>
        <unknowElementFromXSD>OtherValue</unknowElementFromXSD>
  </detail>
</classe>

For example I need JAXB to throw an error for the in this XML file because isn’t define in my XSD.

If someone have an idea, I can’t find any solution on the internet.

  • 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-13T17:22:47+00:00Added an answer on June 13, 2026 at 5:22 pm

    There are a couple of different ways to accomplish your use case:

    Option #1 – ValidationEventHandler

    You can set a ValidationEventHandler on your Unmarshaller to be notified of things like unexpected elements. By default a JAXB (JSR-222) implementation will just ignore unmapped elemeents.

    Option #2 – Schema Validation

    If you set an instance of javax.xml.validation.Schema on the Unmarshaller then the XML input will be validated as it is unmarshalled.

    • http://blog.bdoughan.com/2010/12/jaxb-and-marshalunmarshal-schema.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use JAXB to unmarshall some XML, but I'm getting an Unable
I'm trying to use JAXB to pull some elements from a large XML file
I'm trying to use JAXB to unmashall some XML which I used xjc to
Need: take in XML and save data to database. Currently using: JAXB to convert
I use JAXB to generate Java classes from XML schema. Now I want to
I am trying to use JAXB's introspection to marshall and unmashall some existing domain
I can use this maven plugin maven-jaxb-plugin to generate Java Classes from XSD file.
Is it possible to use JAXB to unmarshall xml to a specific Java class
I use Jersey with JAXB to convert my response to XML. I have several
I need some direction how to best use Exceptions in a Java EE environment,

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.