[rules-users] Drools rules

Wolfgang Laun wolfgang.laun at gmail.com
Sat Apr 23 08:34:10 EDT 2011


This is not a Drools problem, however...

You are using a Domain Specific Language (DSL) to transform rules into
Drools Rule Language (DRL). If you have written the DSL you should know how
it works; if you haven't, then there should be a documentation telling you
what the parameters of
   xpathEquals  "/IATA/messageaudit/@messageVersion" "FSU/13/RCS"
mean, and this would immediately solve your problem. If you had that
documentation (why don't you have it?), it would say that the first
parameter is an XPath expression and the second a value to match at the
location the first expression identifies.

Now, when you use SW using XPath with XML, you should know the basics about
XPath. If you don't - w3c has some good tutorials, see the one on XPath,
here <http://www.w3schools.com/xpath/default.asp>.

The XPath used denotes an attribute and therefore your rules will only work
if messageVersion is an attribute of the element /IATA/messageaudit. In the
second XML, all values are elements below that element.

-W

On 23 April 2011 11:39, annukaila <annu.sifu at gmail.com> wrote:

> Hi
>
> iam new to drools rules my problem is
>
>
> iam receiving message in xml format so using drools have to route it my
> drools rules work when the xml message is the format as below
>
> <?xml version="1.0" encoding="UTF-8"?>
> <IATA>
> <messageaudit senderId="125" receiverId="FFCategory"
> dateTimeOfMessage="19:00"
> messageVersion="FSU/13/RCS" airwaybill="125-1234565" />
> <fsurcs AwbNumber="125-1234565" origin="HYD" destination="KUL"
> totalPieces="T40" totalWeight="K200"
> statusCodeConsignmentRecieveDFromShipperOrAgent="RCS"
> dayAndMonthOfReceipt="02June" actualTimeOfGivenStatusEvent="19:00"
> airportCodeOfReceipt="HYD"
> totalOrPartNumberOfPices="T40" weightOfTotalOrPartOfPieces="K200"
> nameOfAgentOfShipper="Shipper" osi="RcsMessage"/>
> </IATA>
>
> but if the xml is the format as below
>
> <?xml version="1.0" encoding="UTF-8"?>
> <IATA>
> <messageaudit>
> <senderId>125</senderId>
> <receiverId>FFCategory</receiverId>
> <dateTimeOfMessage>19:00</dateTimeOfMessage>
> <messageVersion>FSU/13/RCS</messageVersion>
> <airwaybill>125-1234565</airwaybill>
> </messageaudit>
> <fsurcs>
> <AwbNumber>125-1234565</AwbNumber>
> <origin>HYD</origin>
> <destination>KUL</destination>
> <totalPieces>T40</totalPieces>
> <totalWeight>K200</totalWeight>
>
> <statusCodeConsignmentRecieveDFromShipperOrAgent>RCS</statusCodeConsignmentRecieveDFromShipperOrAgent>
> <dayAndMonthOfReceipt>02June</dayAndMonthOfReceipt>
> <actualTimeOfGivenStatusEvent>19:00</actualTimeOfGivenStatusEvent>
> <airportCodeOfReceipt>HYD</airportCodeOfReceipt>
> <totalOrPartNumberOfPices>T40</totalOrPartNumberOfPices>
> <weightOfTotalOrPartOfPieces>K200</weightOfTotalOrPartOfPieces>
> <nameOfAgentOfShipper>Shipper</nameOfAgentOfShipper>
> <osi>RcsMessage</osi>
> </fsurcs>
> </IATA>
>
>
> it is not routing the message means not recognizing the drools and my
> drools
> file is as follows
>
> package com.jboss.soa.esb.routing.cbr
>
> #list any import classes here.
> import org.jboss.soa.esb.message.Message;
> import org.jboss.soa.esb.message.format.MessageType;
>
> expander XPathLanguage.dsl
>
> #declare any global variables here
> global java.util.List destinations;
>
> rule "Blue Routing Rule using XPATH"
>        when
>                xpathEquals  "/IATA/messageaudit/@messageVersion"
> "FSU/13/RCS"
>        then
>            Log : "Blue Team";
>                Destination : "blue";
> end
>
> rule "Red Routing Rule using XPATH"
>        when
>                xpathEquals  "/IATA/messageaudit/@messageVersion"
> "FSU/13/MAN"
>        then
>             Log : "Red Team";
>                Destination : "red";
> end
>
> rule "Green Routing Rule using XPATH"
>        when
>                xpathEquals  "/IATA/messageaudit/@messageVersion"
> "FSU/13/DEP"
>        then
>             Log : "Green Team";
>                Destination : "green";
> end
>
>
>
> please help me hoe to rectify this its very urgent for me and please dnt
> mind if i did any mistakes
>
>
> thanku
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools-rules-tp2854688p2854688.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110423/f67476c4/attachment.html 


More information about the rules-users mailing list