One from column A and one from column B

I've been trying to work through examples of policies and policy
intersection to make sure I understand the behavior.  I wanted to
double-check a smallish example to make sure I'm on the right track. 
I've cast this in terms of a literal restaurant menu in order to stay
out of the details of particular vocabularies, but I believe that at
least some real-world examples would have a similar shape.  For example,
the appetizers might be authentication policies, the main courses might
be signature algorithms, steamed rice might be reliable transport and so
forth.  So without further ado:

I'm out for lunch.  The restaurant's menu is fairly typical:

<All>
  <ExactlyOne>
    <EggRolls/>
    <SpringRolls/>
    <SteamedDumplings/>
    <FriedDumplings/>
    <CrabRangoons/>
  </ExactlyOne>
  <ExactlyOne>
    <HotAndSourSoup/>
    <WontonSoup/>
    <EggDropSoup/>
  </ExactlyOne>
  <SteamedRice optional="true"/>
  <ExactlyOne>
      <DanDanMein/>
      <HouseSpecialNoodles/>
      <BroccoliBeef/>
      <KungPaoShrimp/>
      <CashewChicken/>
  </ExactlyOne>
  <ExactlyOne>
    <GreenTeaIceCream/>
    <OrangeSlices/>
  </ExactlyOne>
</All>

I'm not trying to capture subtleties here like "no steamed rice with
noodles" or "our lunch special consists of one from column A and /two/
from column B."  Just the basics.

Note that the restaurant SHOULD give its menu in normal form.  I've
omitted that here since it runs to 2500+ lines, but in the real world
2500 lines of XML shouldn't be a burden.

I've got a real hankering for those peppers and peanuts, I definitely
want steamed rice, any kind of dumplings is fine and I'm not in the mood
for ice cream:

<All>
  <ExactlyOne>
    <KungPaoChicken/>
    <KungPaoShrimp/>
  </ExactlyOne>
  <SteamedRice/>
  <ExactlyOne>
    <FriedDumplings/>
    <SteamedDumplings/>
  </ExactlyOne>
  <OrangeSlices/>
</All>

Actually, I SHOULD express that in normal form:

<wsp:Policy>
  <wsp:ExactlyOne>
    <wsp:All>
      <KungPaoChicken/>
      <SteamedRice/>
      <SteamedDumplings/>
      <OrangeSlices/>
    </wsp:All
    <wsp:All>
      <KungPaoChicken/>
      <SteamedRice/>
      <FriedDumplings/>
      <OrangeSlices/>
    </wsp:All
    <wsp:All>
      <KungPaoShrimp/>
      <SteamedRice/>
      <SteamedDumplings/>
      <OrangeSlices/>
    </wsp:All
    <wsp:All>
      <KungPaoShrimp/>
      <SteamedRice/>
      <FriedDumplings/>
      <OrangeSlices/>
    </wsp:All
  </wsp:ExactlyOne>
</wsp:Policy>

Note that I had to peek at the menu to work out that "no ice cream"
means "orange slices".

Now, what's on the menu that I wouldn't mind eating?  I just intersect
the two policies using the rules described in section 4.5 and I get:

<wsp:Policy>
  <wsp:ExactlyOne>
    <wsp:All>
      <KungPaoShrimp/>
      <SteamedRice/>
      <SteamedDumplings/>
      <OrangeSlices/>
      <KungPaoShrimp/>
      <SteamedRice/>
      <SteamedDumplings/>
      <OrangeSlices/>
    </wsp:All
    <wsp:All>
      <KungPaoShrimp/>
      <SteamedRice/>
      <FriedDumplings/>
      <OrangeSlices/>
      <KungPaoShrimp/>
      <SteamedRice/>
      <FriedDumplings/>
      <OrangeSlices/>
    </wsp:All
  </wsp:ExactlyOne>
</wsp:Policy>

which I suppose I could interpret as "Two orders of kung pao shrimp, two
orders of steamed rice, two orders of steamed dumplings and two orders
of orange slices, or two orders of kung pao shrimp, two orders of
steamed rice, two orders of fried dumplings and two orders of orange
slices."

Questions:

    * Modulo the names on the menu, is this the sort of use case WSP is
      aimed at?
    * Did I do the math right?  That is, are the results I gave what the
      framework says they should be?

Received on Monday, 21 May 2007 20:16:24 UTC