[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xslt and fuzzy logic

Subject: RE: xslt and fuzzy logic
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Date: Thu, 24 Jan 2002 08:12:30 -0500
xslt datediff
Hey Brian,

I've written Fuzzy Logic Controllers / Fuzzy Logic Inference Systems during
college and I'm curious: are you wanting to distribute your computation?

For example, distribute pieces of the computation out to multiple nodes
which are controlled by a master node.

In this scenario, I guess I'd consider looking into to the possibility of
using xslt as your computation engine, perhaps using web browsers as
execution environment on the child nodes.

Otherwise, I don't know if I'd use xslt to do intensive computation ...
unless your dealing with small model or if your expectations on performance
are low.  My experience with Fuzzy Logic is that it tended to be bit cpu
intensive, at least the models I was dealing with.

Now, I'm sure there are numerous people on this list that can give you
excellent references and insight on performance issues, but keep in mind
(which I'm sure you are aware of, but just to point out) that transformation
execution is not same as computation execution, which in this case you'll
have to be considering both.  So, to throw more work to transformation side
of the fence, I'd highly suggest staying away from use of call-template
otherwise your forced to have too much conditional logic and have the
overhead of constructing your calls and dealing with the results.

Now, having said all that, I have implemented in xslt something within the
same genre as Fuzzy Logic ... a (simple) rules engine.  So, if--at a high
level--you'd  like to see what I did, then please read on.


I've written a xml based rules engine (I've labeled XRules) that consumes an
xml based language that I wrote.  The engine itself is written in xslt using
nothing but pattern matching--no call-template(s). 

The approach I took could be used to accomplish what you desire here as
well.  My approach may not be the best, but it was relatively straight
forward and the development group picked it up pretty quickly.  And we've
built other xml based languages that use (sub-class if you will) the engine.

Here's how XRules is directly implemented, if not being used as internal
engine by another engine:
	1.  Construct/design an XRule definition file (just an xml document
using the XRule namespace).
	2.  Create an instance of the given document.
	3.  Load the source data (this data is what the XRule definition is
bound to) into the appropriate member (element) of the XRule definition
	4.  "Transform" the XRule definition instance using the XRules
(engine) xslt document.
	5.  Interpret the result document.

Basically, what I do is "serialize" the xml representation into a
multi-valued conditional statement with the source data resolved as the
values for the operands.  Then I use the JScript/JavaScripts eval method to
evaluate the conditional statement via a custom script extension within the
xrule xslt document.

Here's an example:

the xrule definition (in brief):

	Note: this fragment was pulled from a DisplayRules definition file,
this is one of the other languages that uses XRules for its rule evaluation

	<xr:rule id="xrule-01" >
		<xr:context select="//z:row" schema="adoxml"/>
		<xr:param name="DaysBeforeDeliver"  dt:type="number"/>
		<xr:variable name="DaysBeforeDeliverRef" select="@DeliverOn"
		Parent display rule 1:
			If an order is less than x% allocated y days before
the start ship date, 
			then display the allocated quantity and percent in
							If date1 refers to a
later point in time than date2, 
						    	the DateDiff
function returns a negative number
- <xr:value-of select="xr:param(DaysBeforeDeliver)"/> </xr:number>
<xr:value-of select="xr:variable(DaysBeforeDeliverRef)"/> </xr:date>


Then, as part of the process I mentioned above, the source data gets loaded
into the document and then the transform is executed.

Assuming that the DisplayRule definition passes in the value of 7 for the
DaysBeforeDeliver xr:param and the value of @DeliverOn source data attribute
ends up being "2002-30-01" and the current date is "2002-24-01", here's what
the XRules engine does the given xrule definition:
	1.  It "serializes" the xr:condition element into this:
	2.  This statement is then evaluated via the JavaScript's eval
method, which obviously returns true.

The call from the client code, in this case the DisplayRules engine is via a
xr:eval element, which would be return (in this case) a scalar value of 1.

Anyhow, I don't if any of this helped and I've 

-----Original Message-----
From: Bryan Rasmussen [mailto:bry@xxxxxxxxxx]
Sent: Thursday, January 24, 2002 5:54 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  xslt and fuzzy logic

Since I've noticed a lot of academics and people with more background than I
in subjects such as this I thought I'd ask:

Has anyone here ever implemented or seen implemented a fuzzy logic control
in xslt? Does anyone have any ideas on building one in xslt 2.0?

(the following example is halfway hypothetical)

Let's consider that one has three parameters; Display, speed, Function. Each
one is rated on a scale from 1-100 and is passed in from the calling

Display details how important a clear display of a generated page is, with
the understanding that this means uncluttered content, all pictures are
high-res jpgs and stylistic elements are maintained(at a value of a 100)

Speed is how important load time is, if for example load time is given 100
and other parameters are 1 we would assume that we
basically want paragraphs, breaks, & links maintained in our html.

Function presumes that we have a bunch of behaviors, scripts etc. that can
be output to the page space, thereby decreasing display for the main
content, and also decreasing speed. If you choose 100 for this and 1 for the
other values then you want all 20 rss newsfeeds, the multiple soap services,
the calendar, the jabber applet, and so forth :)

I'm sure a lot of us here have made sites/applications where you can switch
between the maximum of two or three wanted parameters by choosing a
dependant branch i.e crisp logic.
What I'm interested in is to evaluate these in a fuzzy way, determining what
to do if display= 48, speed=37, and function=52.

It seems to me that xslt 2.0 and xpath 2.0 would make handling these
problems easier, to the point where it could be a user-define function.

anyhow, any ideas or examples before I make a fundamental mis-step?

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.