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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:28:27+00:00 2026-06-04T00:28:27+00:00

Maybe I’ve been staring at this problem for too long, maybe there isn’t an

  • 0

Maybe I’ve been staring at this problem for too long, maybe there isn’t an answer; either way I’m here now.

I’m trying to permit a set of possible combinations in an XSD, but I can’t seem to find an approach that doesn’t result in ambiguity.

Quick regexy respresentation:

foo+ ( bar baz* | bar? baz+ qux* )
  • foo is required (one-or-more)
  • If bar exists, baz is optional (zero-or-more)
  • If baz exists, bar is optional (zero-or-one) and qux is optional (zero-or-more)
  • qux can not exist if baz does not exist

Ambiguity arises given foo bar baz.

Ambiguous XSD document:

<xs:element name="parent">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="foo" minOccurs="1" maxOccurs="unbounded" />
            <xs:choice>
                <xs:sequence>
                    <xs:element name="bar" minOccurs="1" maxOccurs="1" />
                    <xs:element name="baz" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:sequence>
                    <xs:element name="bar" minOccurs="0" maxOccurs="1" />
                    <xs:element name="baz" minOccurs="1" maxOccurs="unbounded" />
                    <xs:element name="qux" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>
</xs:element>

Screen capture for good measure:

Ambiguous XSD tree


Now, I’m beginning to realize that perhaps this is simply a constraint of the XSD content model. The reason for ambiguity is obvious; the solution not so.

Can anyone see a means with which I can permit this; by re-ordering the elements, through use of some schema design pattern to alleviate ambiguous scenarios like this?

The condition dependency of bar and baz is clearly the problem, but I can’t think of any other way to do this.

Thanks so much in advance folks.


Edit: Currently reading “Schema Component Constraint: Unique Particle Attribution” in an attempt to find a loop-hole. Any other suggested reading welcome.

  • 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-04T00:28:28+00:00Added an answer on June 4, 2026 at 12:28 am

    IIRC there is a theorem in computer science that says every ambiguous grammar can be rewritten as an unambiguous grammar, so start with the hypothesis that it’s possible. However, the unambiguous grammar can sometimes be hideously complex.

    I think a good approach to handling this is to draw the “railroad diagram” of the grammar, that is, the finite state machine with its transitions. Then when you find a state in this machine that has two transitions labelled with the same symbol, you need to construct a new state that accepts both those transitions, and so on. In the CS literature this algorithm is called “determinization”.

    Another approach which is perhaps easier to explain without a whiteboard is to start by factoring out what is common between the two branches of your choice. When you hit the first element in the content, it has to be either a bar or a baz. So write two choices, one starting with bar and one with baz.

    As far as I can see, your content model is euiqvalent to the unambiguous model

    (bar, (baz+, qux*)?) | (baz+, qux*)
    

    but I would check that carefully…

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

Sidebar

Related Questions

Maybe there is no difference, but is either way better than the other (or
Maybe this is something I am just missing, but is there any way to
Maybe this is a dumb question! I'm just wandering is there any way/web part
Maybe there is a package to do this, but I have not been able
maybe this might be a simple problem but after a long while at Google
Maybe this is a dumb question, but is there any way to convert a
Maybe I'm just thinking about this too hard, but I'm having a problem figuring
Maybe I've been drinking too much of the functional programming Kool Aid, but this
Maybe this is a simple question, but I didn't find answer in web. I
Maybe this is a no-brainer but i cant see the solution right now :)

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.