Solved

NEWBIE: How to store boolean logic in XML?

Posted on 2007-11-21
1
1,261 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get last 10 digits of an xsl value-of field 7 59
Removing information on Duplicate XML Nodes 24 77
Trouble parsing soap xml result 3 49
XML XSL Message 3 21
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

785 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