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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:01:14+00:00 2026-05-20T15:01:14+00:00

Is it possible to distinct xs:choices in xsd by using fixed values? I have

  • 0

Is it possible to distinct xs:choices in xsd by using fixed values? I have a simple type:

<xs:simpleType name="datatypeCategory">
    <xs:restriction base="xs:string">
        <xs:enumeration value="SIMPLE"/>
        <xs:enumeration value="COMPLEX"/>
        <xs:enumeration value="COLLECTION"/>
    </xs:restriction>
</xs:simpleType>

And what I want to achieve is

<xs:element name="datatype">
    <xs:complexType>
        <xs:choice>
            <xs:sequence>
                <xs:element id="category" type="datatypeCategory" fixed="SIMPLE"/>
                <!-- some fields specific for SIMPLE -->
            </xs:sequence>
            <xs:sequence>
                <xs:element id="category" type="datatypeCategory" fixed="COMPLEX"/>
                <!-- some fields specific for COMPLEX -->
            </xs:sequence>
            <xs:sequence>
                <xs:element id="category" type="datatypeCategory" fixed="COLLECTION"/>
                <!-- some fields specific for COLLECTION -->
            </xs:sequence>
        </xs:choice>
    </xs:complexType>
</xs:element>

When I do this my XMLSpy tells me:

# The content model of complex type definition '{anonymous}' is ambiguous.
# Details: cos-nonambig: <xs:element name='category'> makes the content model non-deterministic against <xs:element name='category'>. Possible causes: name equality, overlapping occurrence or substitution groups.
  • 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-20T15:01:15+00:00Added an answer on May 20, 2026 at 3:01 pm

    You can’t do exactly that. The error is because a simple validator that sees a <category> element won’t immediately know which branch of the choice to take, and XML Schema 1.0 supports such simple validators.

    An alternative would be to name each element according to the category.

    <xs:element name="datatype">
        <xs:complexType>
            <xs:choice>
                <xs:sequence>
                    <xs:element name="simpleCategory" type="empty"/>
                    <!-- some fields specific for SIMPLE -->
                </xs:sequence>
                <xs:sequence>
                    <xs:element name="complexCategory" type="empty"/>
                    <!-- some fields specific for COMPLEX -->
                </xs:sequence>
                <xs:sequence>
                    <xs:element name="collectionCategory" type="empty"/>
                    <!-- some fields specific for COLLECTION -->
                </xs:sequence>
            </xs:choice>
        </xs:complexType>
    </xs:element>
    

    where empty is defined as an empty type. Or give them complex types to hold the “specific fields”. There are other alternatives depending on your constraints, such as using substitution groups or derived complex types.

    In general though, XML Schema 1.0 is not good for constraints based on interrelated values. For that, you have to go to XML Schema 1.1 or an external tool.

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

Sidebar

Related Questions

Is it possible to select DISTINCT values using Rails3 JQuery autocomplete gem?
is it possible to use PostgreSQL-like DISTINCT ON in EJB using named query? o.fromDate,o.empLeaveMasterId,o.employeeInfoId,
Possible Duplicate: Java - Distinct List of Objects i have a sorted array of
How can we identify distinct computers/devices on an intranet? This is possible using cookies
I have a simple product list, the products fall into two distinct categories and
We're using PostgreSQL v8.2.3. Is it possible to get DISTINCT rows from an UPDATE
Assume I have a such model: class Foo(models.Model): name = models.CharField(ad,max_length=25) type = models.ForeignKey(Type)
select count(distinct id) from svn where name='ant' and type='Bug' and select count(distinct id) from
What column does DISTINCT work with in JPA and is it possible to change
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have

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.