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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:56:33+00:00 2026-05-30T00:56:33+00:00

I have xml files: <Parent> <Child1 … /> <Child2 … /> … <Child1 …

  • 0

I have xml files:

<Parent>
  <Child1 ... />
  <Child2 ... />
  ...
  <Child1 ... />
  <Child1 ... />
<Parent>

Where Clild1 and Child2 – childrens of Parent abstract class.

That is, the question was:
How to set a validation scheme for the collection that can have any number of elements different types?

Best regards!

  • 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-30T00:56:34+00:00Added an answer on May 30, 2026 at 12:56 am
    <xs:element name="Parent">
      <xsl:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="Child1"/>
          <xs:element name="Child2"/>
        </xs:choice>
      </xs:complexType>
    </xs:element>
    

    To illustrate how this works let’s use a simplified version of your example input.

    <Parent>
      <Child1 ... />
      <Child2 ... />
      <Child1 ... />
      <Child1 ... />
    </Parent>
    
    1. The validator looks at the first element.<Parent> is the first element so validates.
    2. The validator then looks for the complex type inside of parent. It finds <Child1>. Since <Child1> is the first element in the choice block it validates.
    3. The validator then looks for the <Child2> element. Since <Child2> is next it also validates.
    4. The validator then looks at the next element. It is not </Parent> so the validator checks it against the choice block since it can occur an unlimited number of times as maxOccurs=unbounded.
    5. The validator finds a <Child1> element which validates.
    6. The validator looks for a <Child2> element which doesn’t exist so it finishes the choice block.
    7. The validator then looks at the next element. It is not </Parent> so the validator checks it against the choice block since it can occur an unlimited number of times as maxOccurs=unbounded.
    8. The validator finds a <Child1> element which validates.
    9. The validator then looks at the next element. It is </Parent> which validates.
    10. The validator is done. The document validates successfully.

    Since minOccurs=0 this also allows for the case where there is 0 occurrences of a <Child1> or <Child2> element. XML schema elements inherit the properties of their parent elements unless explicitly declared. In this case, since we did not declare a minOccurs property for either <Child1> or <Child2> this is the equivalent of <xs:element minOccurs="0" name="Child1"/> and <xs:element minOccurs="0" name="Child2"/>.

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

Sidebar

Related Questions

I have XML files in a directory that I wish to get over to
I have two XML files that are generated by another application I have no
I have some xml files that contain text, which are displayed on my website.
I have XML files containing data like this... <parent> <boy/> </parent> <parent> <girl/> <parent>
I have a class: public class Chid1 : Parent{ public string var1{get;set;} public string
To start off, I have this XML file that contains recursive parent-child elements. Here
I have maven multiple-module project. A: parent. B: child1. C: child2. B will be
I have xml files I want to read in and store in the database.
I have several xml files, the names of which are stored in another xml
I have two XML files with two different XSD schemas and different namespaces. They

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.