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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:13:59+00:00 2026-06-01T07:13:59+00:00

I have a Java program in which I have to validate an XML message

  • 0

I have a Java program in which I have to validate an XML message against an XSD schema. So far so good. But now I got a new requirement where part of the validation is different based on the content of the XML message.

So based on the value of one field (1) some fields are nillable or not and some enumerations are different. However I can’t parse the document before validation… so how should I cope with this?

1) Have 2 different XSD files, handle the XML as text (=ugly) and extract the one field to decide what XSD should be used?

2) Have 3 different XSD files. The 2 different options and one union so we can validate in a way that matches the 2 options? Than we can properly parse the XML, extract the field and decide which more specific XSD to use for extra validation?

3) Other options?

  • 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-01T07:14:01+00:00Added an answer on June 1, 2026 at 7:14 am

    Don’t parse it with JAXB then but rather with SAX/StAX type parser (or DOM if you really want to, though SAX would be faster if you just need handful of elements) to locate and analyze element(s) you need in order to determine proper schema which would need to be used. Once you collected enough information, abort parsing and parse again with proper schema validation.

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

Sidebar

Related Questions

We have a Perl program to validate XML which is invoked from a Java
I now have a running Java program which only lacks of the final step,that
I have a program which i have myself written in java, but I want
I have a java program which is using the default XML logging as no
I have java program which receives encrypted message through TCP/IP from one component of
I have a Java program which is using WMIC to get certain information about
I have a java program which sends a udp packet to a server when
I have a Java program which prepares data into a fairly complex and big
I have a Java program in which an action is initiated which loops through
How to write a java program which will tell me whether I have internet

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.