Sibling bindings

34 views
Skip to first unread message

Gabriel Piacenti

unread,
Mar 4, 2025, 3:26:53 PMMar 4
to Drools Usage
I'm trying to write something using the OOPath notation and I'm having some problems dealing with sibling bindings
I want to do something like this

/a[$aBinding:this, /b[some conditions, $bBinding: this], /c[some conditions, $cBinding: this]

Since the data is hierarchical I can't really separate these very well but the b and c bindings share the same parent. The main problem is that an OOPath like the above ends up in an error like "Only one oopath per pattern is allowed".
I am using the latest version of Drools (10)

Is there some syntax issue or limitation I'm hitting here?

Alex Porcelli

unread,
Mar 4, 2025, 6:21:15 PMMar 4
to drools...@googlegroups.com
Can you share a more concrete example?

Regards,
_____________
Alex Porcelli
http://porcelli.me


--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/drools-usage/60cd0042-beee-4ca9-80ac-e1416318d61en%40googlegroups.com.

aas...@gmail.com

unread,
Mar 5, 2025, 10:13:53 AMMar 5
to Drools Usage
> /a[$aBinding:this, /b[some conditions, $bBinding: this], /c[some conditions, $cBinding: this]
You are missing one "]" here.

You should be able to write something like this if that helps:

$aBinding: /a
$bBinding: /b[some conditions]
$cBinding: /c[some conditions]

Note there are no commas at the end of the lines.

Juhan

Gabriel Piacenti

unread,
Mar 5, 2025, 2:18:27 PMMar 5
to Drools Usage
I can do the following but it does seem a bit wasteful
/a[$aBinding:this]/b[some conditions, $bBinding: this]
/a[this==$abinding]/c[some conditions, $cBinding: this]

If there is no branching that can be done for binding in a single path, at least this can do it by making sure it is operating off of the same parent

Gabriel Piacenti

unread,
Mar 5, 2025, 3:55:30 PMMar 5
to Drools Usage
yeah, sorry that was a mistake when copying over but I had the proper closing brackets, non trailing commas when I tried to run things. 

An analogous use case could be that I have a list of locations, each with a list of builds in them as well as other data such as a list of street lights, or fire hydrants. So basically I would like a binding to the location and bindings to specific street lights or hydrants under that location. So those just happen to be sibling lists of objects and from what I tried out it doesn't seem possible to bind to these items in a single path but may rather require multiple paths like I did in my workaround solution I posted.

Reply all
Reply to author
Forward
0 new messages