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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:37:14+00:00 2026-06-10T01:37:14+00:00

I am writing some XSD and I only have a basic understanding of the

  • 0

I am writing some XSD and I only have a basic understanding of the <choice> tag. I have it working with one section, but not another section that has an attribute.

For example, all elements are optional, but if I don’t have one, then I need to have the other. This is fine if there is 2 elements, but I have 3.

Look at the schema section below. I can either have message or scan and not include, or I can have include and not message or scan.

       <xs:element name="messages">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" ref="n:properties"/>

        <xs:choice>
          <xs:sequence>
            <xs:element ref="n:message" maxOccurs="unbounded"/>
            <xs:element ref="n:scan" minOccurs="0"/>
          </xs:sequence>

          <xs:element ref="n:scan"/>
        </xs:choice>

              <xs:attribute name="include"/>
          </xs:sequence>
        </xs:complexType>

  </xs:element>

At the moment, this is working for message and scan but gives me an error on include obviously, because I don’t have the choice put in there yet.

Can anyone show me some samples of how I’d do (message OR scan) OR include?

Thanks

  • 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-10T01:37:16+00:00Added an answer on June 10, 2026 at 1:37 am

    By far the simplest way to say “either A or B or C” is to make A, B, and C all be elements and write

    <xs:choice>
      <xs:element ref="A"/>
      <xs:element ref="B"/>
      <xs:element ref="C"/>
    </xs:choice>
    

    An alternative would be to say “including messages from another file is not the same as specifying a message” and define both n:messages (which contains either a message or a scan) and n:message-inclusion (which points to another file). In the parent element allow either. Or define an abstract message-thingy element and put n:messages and n:message-inclusion into its substitution group.

    A second alternative: move to XSD 1.1 and use an assertion to enforce the rule that the include attribute is present iff the children are absent.

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

Sidebar

Related Questions

Im writing some helper functions for a project im working on. I've always wanted
Just writing some CSS and I have a pretty cool Search form where you
I am writing some BASH script and I want it have some error handling
I'm writing some code that will take a screenshot of another application, given its'
I'm writing the xsd and the code to validate, so I have great control
Writing some classes for a Framework extension, and I have the following code: public
I have some trouble writing some code (I might be tired), so I need
I'm writing some custom helpers the current one involves a sort of datagrid control
I writing some ADT on C: I have two file date.c and date.h inside
In writing some tests for a project I'm working on, I found that the

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.