Solved

NEWBIE: How to store boolean logic in XML?

Posted on 2007-11-21
1
1,257 Views
Last Modified: 2008-02-01
Dear Experts,

I have a dumb question.  Assume I want to store three test questions, in which BOTH of the first two are true, OR the third is true.  For instance, "If ((Birdie is blue) AND (Duckie is yellow)) OR (Bear is purple)..."

(I said this was a dumb question...)  

One way I can think of storing this would be to literally include something like parentheses and logical operators, like this:

<PAREN>
  <PAREN>
    <TEST>Birdie is blue</TEST>
    <OPERATOR>AND</OPERATOR>
    <TEST>Duckie is yellow</TEST>
  </PAREN>
</PAREN>
<OPERATOR>OR</OPERATOR>
<TEST>Bear is purple</TEST>

But there must be a better way, right?  The PARENs, in particular, seem very klutzy.  Is there a way to get their functionality directly from XML?

Thanks!
BrianMc1958
0
Comment
Question by:BrianMc1958
1 Comment
 
LVL 16

Accepted Solution

by:
McExp earned 500 total points
ID: 20329961
I would structure the XML as follows:-
<TEST Op="OR">

  <OPERAND1>

    <TEST Op="AND">

      <OPERAND1>Birdie is blue</OPERAND1>

      <OPERAND2>Duckie is yellow</OPERAND2>

    </TEST>

  </OPERAND1>

  <OPERAND2>Bear is purple</OPERAND2>

</TEST>

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now