can you post the contents of 'CBRWorkRules.drl'?
Here it is:
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 "Ok Routing Rule using XPATH" when xpathEquals expr "xmldata/record/status", "1" then Log : "Job status ok"; Destination : "ok"; end rule "Invalid Routing Rule using XPATH" when xpathEquals expr "xmldata/record/status", "" then Log : "Empty Job status"; Destination : "invalid"; end
xpathEquals expr "xmldata/record/status", " "
Notice the extra space there.
I tried putting different values between the quotes but it still seems to complain about the xpathEquals:
Unexpected token 'xpathEquals'
am I missing any semicolon or something?
I also tried replacing xpathEquals with xpathGreaterThan and xpathLessThan and it complains that
Unable to expand: xpathLessThan expr "xmldata/record/status", "1"[13,2]: unknown:13:2 Unexpected token 'xpathGreaterThan'[23,2]: unknown:23:2 Unexpected token 'xpathLessThan'
It seems like it does not load the XPathLanguage.dsl
can you send me your .esb archive and I'll take a look?
It looks like XPathLanguage.dsl will work only if the XML has namespaces defined and then you use the "use namespaces" expression.
xpathEquals expr "/order:Order/@statusCode", " " use namespaces "order=http://org.jboss.soa.esb/Order"
How would I change the .dsl file to support XML without namespaces? like this:
xpathEquals expr "/Order/@statusCode", " "
Looks like the namespace unaware methods don't work. Could you verify this on your side?
When using xpath dsl without namespaces we needed the expressions to be different.
So the one without namespaces should be:
xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "1"
and the one that uses namespaces:
xpathEquals expr "/order:Order/@statusCode", "2" use namespaces "order=http://org.jboss.soa.esb/Order"
Notice that the namespace aware statements differ in that they need the extra 'expr' in front of the XPath expression. This is do avoid colliding with the non XPath aware statements in the dsl file.
This is mentioned in the "XPath Domain Specific Language" in the ServiceGuide.pdf but I had forgotten about it. Sorry about that.
Thank you. That did it! At least for the standard xpath methods included in the ESB.
One last question... if I have a newdsl.dsl file and I include it in my rules(.drl) like this
what is the proper location for the .dsl file? inside of the jbossrules.esb?
I tried putting it inside of my .esb archive but I get a message:
Unexpected token 'xpathBoolean'
inside my rule I have
xpathBoolean "xmldata/record/id = 12345"
Yes, that is the correct location.
Did you update the dsl in jboss-esb.xml aswell:
<property name="ruleLanguage" value="NewDsl.dsl"/>
I didn't realize that it needs to be included both in the .drl file and the jboss-esb.xml.