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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:09:21+00:00 2026-06-17T15:09:21+00:00

I have an xml document which is produced by a process which I cannot

  • 0

I have an xml document which is produced by a process which I cannot change. It looks a little like this:

<root>
  <foo bar="..." baz="..."/>
  <foo bar="..." baz="..."/>
  <foo bar="..." baz="..."/>
  <foo/>
  <foo/>
</root>

I’ve got a schema set up to require attributes baz and bar on a foo element, because they’re required for the program which reads the file to run correctly. However, the program generating the xml sometimes adds one or more empty foo elements to the end, as shown above. This causes the schema validation to fail, but I don’t want to relax the schema to allow empty foo elements as this could cause the program to fail.

Does anyone have a suggestion of what the best approach to solving this problem is? The only solution I’ve thought of so far is to pre-process the xml, removing any empty foo elements, but it’s a bit hideous.

  • 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-17T15:09:23+00:00Added an answer on June 17, 2026 at 3:09 pm

    There’s no way in XSD 1.0 of saying that some of the foo elements have different validation rules applied from other foo (sibling) elements. You could do it in XSD 1.1 with an assertion.

    Transforming before validating is not actually such a bad thing to do. If you know what noise you need to remove from a document before validating it and then doing the real processing, then inserting a transformation step into the pipeline before the validation can be a very effective technique.

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

Sidebar

Related Questions

I have got an XML document which looks something like this. <Root> <Info>....</Info> <Info>....</Info>
I have an XML document which looks something like this: <meadinkent> <record> <comp_div>MENSWEAR</comp_div> <sty_ret_type>ACCESSORIES</sty_ret_type>
I have an xml document which looks like this: <Applications> <myApp> <add key=ErrorDestinationEventLog value=EventLog
I have a XML document which looks something like this: <events> <event category=gymnastics subcategory=rhythmic
I have an XML document which contains nodes like following:- <a class=custom>test</a> <a class=xyz></a>
I have the following XML document which I would like to parse into a
I have an XML document which is confounding me. I'd like to (to start)
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
I have an XML Document which has attributes with a namespace. The XML looks
I have an xml document which consists of a number of the following: -

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.