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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:48:55+00:00 2026-06-02T23:48:55+00:00

How can I enforce to chose at lease one, but no repeat? The following

  • 0

How can I enforce to chose at lease one, but no repeat?

The following syntax allows any c element to repeat up to 3 times.

<choice minOccurs="1" maxOccurs="3">
    <element name="c1" type="string" />
    <element name="c2" type="string" />             
    <element name="c3" type="string" />
</choice>

thnx

steve

  • 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-02T23:48:58+00:00Added an answer on June 2, 2026 at 11:48 pm

    Loose the maxOccurs="3" and what you got is “choose at least one”, no repeat.

    For particles, the default is minOccurs="1"; a mandatory choice, where each option particle is itself mandatory, is your answer.

    UPDATE: Based on your comment, if what you’re looking is for any ordered combination of the particles you’ve described, this is the best you can get with XSD spec.

    <?xml version="1.0" encoding="utf-8" ?>
    <xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="root">
            <xsd:complexType>
                <xsd:choice>
                    <xsd:sequence>
                        <xsd:element ref="c1"/>
                        <xsd:element ref="c2" minOccurs="0"/>
                        <xsd:element ref="c3" minOccurs="0"/>
                    </xsd:sequence>
                    <xsd:sequence>
                        <xsd:element ref="c2"/>
                        <xsd:element ref="c3" minOccurs="0"/>
                    </xsd:sequence>
                    <xsd:element ref="c3"/>
                </xsd:choice>
            </xsd:complexType>
        </xsd:element>
        <xsd:element name="c1" type="xsd:string"/>
        <xsd:element name="c2" type="xsd:string"/>
        <xsd:element name="c3" type="xsd:string"/>
    </xsd:schema>
    

    This is messy already; if you’re looking for a greater number of particles or any unordered combination, then I would change the model to something like this (these are XSD 1.0 limitations in action – it all has to do with limitations in the XPath syntax you can use for selectors/fields).

    <?xml version="1.0" encoding="utf-8" ?>
    <xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="root">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element ref="c" maxOccurs="unbounded"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:key name="pk">
                <xsd:selector xpath="*"/>
                <xsd:field xpath="@code"/>
            </xsd:key> 
        </xsd:element>
        <xsd:element name="c" type="TC" abstract="true"/>   
        <xsd:element name="c1" type="TC1" substitutionGroup="c"/>
        <xsd:element name="c2" type="TC2" substitutionGroup="c"/>
        <xsd:element name="c3" type="TC3" substitutionGroup="c"/>
    
        <xsd:complexType name="TC">
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="code" type="xsd:string"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
        <xsd:complexType name="TC1">
            <xsd:simpleContent>
                <xsd:restriction base="TC">
                    <xsd:attribute name="code" type="xsd:string" fixed="c1"/>
                </xsd:restriction>
            </xsd:simpleContent>
        </xsd:complexType>
        <xsd:complexType name="TC2">
            <xsd:simpleContent>
                <xsd:restriction base="TC">
                    <xsd:attribute name="code" type="xsd:string" fixed="c2"/>
                </xsd:restriction>
            </xsd:simpleContent>
        </xsd:complexType>
        <xsd:complexType name="TC3">
            <xsd:simpleContent>
                <xsd:restriction base="TC">
                    <xsd:attribute name="code" type="xsd:string" fixed="c3"/>
                </xsd:restriction>
            </xsd:simpleContent>
        </xsd:complexType>  
    </xsd:schema>
    

    A sample XML would like this:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">
        <c1 code="c1">c11</c1>
        <c2 code="c2">c21</c2>
        <c3 code="c3">c21</c3>
    </root>
    

    or this:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">
        <c2 code="c2">c21</c2>
        <c1 code="c1">c11</c1>
    </root>
    

    Basically you’re keying in on some component that makes your element unique, that is part of the data as opposed to a tag name. Again, messy, but as an exercise, it may give you an idea.

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

Sidebar

Related Questions

Can any one tell, how to get the result of LINQ query contains group
How can one enforce an order of callbacks? For example, how do you ensure
I need a little help on how I can enforce the following constraints on
Is there any way I can enforce a method returning something along the lines
How can I enforce the JFileChooser filetype (when saving). I have implemented a file
I would expect subclass always call super() for some method. How can I enforce
I'm looking for a script/tool that can be customized to check and enforce coding/naming
Simple question. Just wondering if this can be done without me having to enforce
I read that compiler can enforce dbc at compile time.. How does it do
I am trying to build a simple abstract Cache class that can enforce methods

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.