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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:02:46+00:00 2026-06-16T01:02:46+00:00

I am validating some XML against this XSD: <xs:element name=Composite> <xs:complexType> <xs:sequence minOccurs=0 maxOccurs=unbounded>

  • 0

I am validating some XML against this XSD:

  <xs:element name="Composite">
    <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="HeldCurrency" type="mstns:HeldCurrencyType"  nillable="true"/>
        <xs:element name="Component" type="mstns:ComponentType" nillable="true" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute  name="Type" type="mstns:compositeType" use="required"/>
    </xs:complexType>x
  </xs:element>

  <xs:complexType name="HeldCurrencyType">
    <xs:attribute  name="CashPerCreationUnit" type="xs:double" />
    <xs:attribute  name="CashCurrency" type="xs:string" />
    <xs:attribute  name="ClosingSpotFx" type="xs:double" />
  </xs:complexType>

  <xs:complexType name="ComponentType">
    <xs:choice>
      <xs:element name="Weight" type="xs:double"/>
      <xs:element name="Units" type="xs:int"/>
    </xs:choice>
    <xs:attribute name="Symbol" type="xs:string" />
  </xs:complexType>

  <xs:simpleType name="compositeType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Index" />
      <xs:enumeration value="Etf" />
    </xs:restriction>
  </xs:simpleType>

When I run the following XML against it:

<?xml version="1.0"?>
<Composite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Type="Etf" xmlns="urn:xxx-au:index-types">
  <HeldCurrency />
  <Component />
</Composite>

I run this in C#/.Net4.0 with the following code:

using (FileStream fileStream = File.OpenRead("./Xml/Components.xsd"))
{
    using (var schemaReader = new XmlTextReader(fileStream))
    {
        settings.Schemas.Add(null, schemaReader);
        settings.ValidationType = ValidationType.Schema;
        settings.ValidationEventHandler += OnValidationEventHandler;

        using (FileStream infile = File.OpenRead(filename))
        {
            using(var xmlReader = XmlReader.Create(infile,settings))
            {
                var serialiser = new XmlSerializer(typeof (Composite));
                _composite = (Composite) serialiser.Deserialize(xmlReader);
            }
        }
    }
}

I get the following error:
The element ‘Component’ in namespace ‘urn:xxx-au:index-types’ has incomplete content. List of possible elements expected: ‘Weight, Units’ in namespace.
However, I have minOccurs=”0″ so why would this be an issue? It is legal for the sequence to contain no ComponentType elements after all, right?

Thanks in advance.

  • 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-16T01:02:47+00:00Added an answer on June 16, 2026 at 1:02 am
    <xs:element name="Component" type="mstns:ComponentType" nillable="true" minOccurs="0"/>
    

    The minOccurs here is for specifically the “Component” element — not its contents. ComponentType has content of xs:choice, which does not have a minOccurs of 0. So you can omit “Component” entirely, but not its contents.

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

Sidebar

Related Questions

I have a schema containing (for example)... <xsd:complexType name=mytype> <xsd:sequence> <xsd:any maxOccurs=unbounded processContents=skip/> </xsd:sequence>
This is the schema in my.xsd : <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:p='some-namespace' targetNamespace='some-namespace'> <xs:element name='root' type='p:main'/>
I'll admit, I'm an XML newbie. I'm having trouble validating some xml against a
I am validating XML documents against a schema. Some more complex documents/schemas always fail
I have some Java code that validates XML against an XSD. I am using
I am validating an in-memory DOM object using the javax.xml.validation.Validator class against an XSD
I know there are quite some threads talking about validating XML file against its
The HTML5 spec defines some very interesting validation components, including pattern (for validating against
I have an XML file that is validating against a schema. However on our
This is similar to this question C# Get schema information when validating xml However,

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.