473,385 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Xpath expression/queries ideas for this rule engine using the db

This is what Nick Malik suggested from the c# newsgroup. Now that the hectic
workweek is over, I can begin to appreciate what he said and break it down
into constituent elements to solve. If anyone has any implementation
examples related to what Nick describes below, they would be
ppreciated. -hazz

One thing you could do is to place your rules in a database. Each rule
consists of an XPath expression for the operand, and operator, the value you
compare against, and the score. Bring your data into your system and
serialize it into an XML document. Then, apply each of the Xpath queries to
the object, one at a time. If the query produces a result, you have a value
you can compare against. Apply the comparison and, if true, add the score
to your accumulated score.

This will work regardless of the data coming in, and your storage mechanism
can work for anything. Xpath queries are very powerful and you can
differentiate easily depending on the structure of the inbound document, so
that a query may match a value only if it is at a particular place in the
document, or anywhere in the document... up to you.

Total lines of code < 200. Highly flexible since you can add and delete
rules in the db at any time.
Nov 21 '05 #1
1 1647
Sample Rule components
Table Column op value score
Buy Budget > 500000 10
Buy Budget < 500000 5
Sell In6mths = Yes 10
Sell In6mths = No 5

Object to evaluate
CustomerID 1
Budget (Dollars) 10000
Sell (TimeFrame) 7 months
CustomerID 2
Budget (Dollars) 500001
Sell (TimeFrame) 3 months
CustomerID 3
Budget (Dollars) 600000
Sell (TimeFrame) 12 months
Evaluating objects against rules would yield scores for each object, eg.
CustomerID - Score
If Buy then
1 5
2 10
3 19

If Sell then
1 5
2 10
3 5
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using...
1
by: gimme_this_gimme_that | last post by:
I have the following xml file and need some tips on xpath queries to fetch the data. I think I'm not handling namespaces correctly. Here is xml file : <?xml version="1.0"...
4
by: MarcoT77 | last post by:
Hi Teacher. I'm trying to get with Xpath the Product nodes in the following XML: <?xml version="1.0" encoding="utf-8"?> <PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema"...
2
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
2
by: hazz | last post by:
Does anyone have any ideas on how to implement what has been suggested for my 'rules engine'? thx, -hazz the following are rules in the sql server table, one row for each rule. Table Column ...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
14
by: Mikhail Teterin | last post by:
Hello! What's would be the syntax for a query, which would allow me to get only the elements with non-empty text-nodes? For example, from: <a><b></b></a> <c/> <d><e>meow</e></d>
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.