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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:49:56+00:00 2026-05-27T04:49:56+00:00

Is it possible using one or more XSDs to validate the following xml structure

  • 0

Is it possible using one or more XSDs to validate the following xml structure

<container>
    <unkownA />
    <unkownB />
    <unkownC />
    ...
    <data />
</container>

by those rules

  1. there is an unlimited number of unkown elements
  2. there is at least one of those unkown elements
  3. the last element is data
  4. data occurs only once
  5. data is validated according to provided rules

All the elements in the xml have the same namespace (“”), which we can’t change.
We are most likely not able to change the order of the elements as well, though I know this is probably the easiest solution.
Changing the xml in general is not an viable option, since it is generated by a external system we don’t control.

I tried something like this

<xs:sequence>
   <xs:any minOccurs="1" maxOccurs="unbounded" processContents="lax" />
   <xs:element ref="data" minOccurs="1" />
</xs:sequence>

which of course, being ambiguous, violates the “Unique Particle Attribution”.

I also read about the use of a second namespace here Creating a 'flexible' XML schema
but since we can’t change the xml this does not seem to be a solution or I plainly don’t understand it properly.

By the we are using Java to process the xml/xsd, the xsd resides in the classpath, so xs:import from within an xsd might be a problem.

If the answer is “This can’t be done with xsd within these constraints” I’m fine with it.

So any ideas?

  • 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-27T04:49:57+00:00Added an answer on May 27, 2026 at 4:49 am

    What finally worked, even if it does not make me happy:

    javax.xml.validation.SchemaFactory schemaFactory = SchemaFactory
            .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    
    schemaFactory
        .setFeature(
            "http://apache.org/xml/features/validation/schema-full-checking",
            false);
    

    This seems to disable the validation of the schema itself.
    The validation of the xml works as expected and described above.
    And yes, I know: Disabling security/sanity features that are actived by default might not be a good idea. But till know there wasn’t any time to find a better way.

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

Sidebar

Related Questions

Is it possible to declare more than one variable using a with statement in
In C# and Java, it's possible to create constant strings using one or more
Is it possible to mount a local directory into another one? Using Perforce, I
Using pointer arithmetic, it's possible to assign characters from one array to another. My
Is it possible using StAX (specifically woodstox) to format the output xml with newlines
Is it possible using Linq to create a group where items fall into more
I am working on an Android application that parses one or more XML feeds
In Common-Lisp CLOS Is it possible to dynamically add one more super class in
Is it possible using jQuery to select all <a> links which href ends with
Is it possible using CAML to limit the amount of results returned. Say for

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.