I am not the right person to be answering your questions since I would not have expected these rules to compile. If they compile then what you are doing must be at least syntactically correct, but I won't be much help since you are using syntax I am not familiar with.
  I don't understand how you are able to reference fields of the objects with all upper case letters when the field names are all lower case. Does JAXP generate get methods for those fields? If so, perhaps those methods use all uppercase for the field names?
  I write rules with simple condition expressions that work with a flat object model. I didn't even know DRL syntax allowed rules that referenced sub-fields or array elements in the condition part (i.e. GEO[0].POSITION.LOC_ID) unless we used an eval expression.
  If I were doing what you are trying to do, I'd use an eval expression (which can handle any java boolean expression):
                        OASISTSO10($e: EVENT)
                        eval($e.GEO[0].POSITION.LOCID.equals( “40005”))

Otaduy del Paso, Zaloa [10/7/2008 11:51 AM] wrote:



The rules I have now, compile. The generated jaxb classes I have regarding to what I’m trying to do are:


public class EVENT {


    @XmlElement(name = "EVENT_ID", required = true)

    protected String eventid;


        @XmlElementRef(name = "NODE_ID", namespace = "", type = JAXBElement.class),

        @XmlElementRef(name = "OTHER_EVENT_ID", namespace = "", type = JAXBElement.class)


    @XmlElement(name = "GEO")

    protected List<EVENT.GEO> geo;

    @XmlElement(name = "PREDICTED_CASUALTIES")

    protected List<EVENT.PREDICTEDCASUALTIES> predictedcasualties;

    @XmlElement(name = "TREND")

    protected String trend;





public static class GEO {


        @XmlElement(name = "DESCRIPTION", required = true)

        protected String description;

        @XmlElement(name = "POSITION", required = true)

        protected POSITION position;

        @XmlElement(name = "WEATHER")

        protected List<String> weather;

        @XmlElement(name = "TEXT")

        protected String text;



public class POSITION {


    @XmlElement(name = "LOC_ID")

    protected String locid;

    @XmlElement(name = "NAME")

    protected String name;

    @XmlElement(name = "COORD")

    protected POSITION.COORD coord;



public static class COORD {



            @XmlElementRef(name = "LON", namespace = "", type = JAXBElement.class),

            @XmlElementRef(name = "HEIGHT", namespace = "", type = JAXBElement.class),

            @XmlElementRef(name = "LAT", namespace = "", type = JAXBElement.class)




I hope this is enough to understand what I’m working with. Sorry if I didn’t explain myself correctly.


Thanks in advance,

Zaloa Otaduy del Paso

De: [] En nombre de Scott Reed
Enviado el: martes, 07 de octubre de 2008 17:39
Para: Rules Users List
Asunto: Re: RV: [rules-users] Checking an xml field


You haven't answered my question as what the problem is. Do these rules compile?
It seems to me that you have misunderstood how the condition part of the rules work.
I agree with David that it would help for you to study the manual some more and to work through some of the tutorials.
Since this is a Drools forum, there are probably not a lot of folks who understand exactly how JAXP translates the XML into beans. You are more likely to get help here if you include the relevant portions (get methods) of the API output by JAXP.

Otaduy del Paso, Zaloa [10/7/2008 11:22 AM] wrote:

Hi David,


Thanks for your helpful response. The problem was that the element GEO can appear 0 or many times so what I needed to write was this



                        OASISTSO10($e: EVENT)

                        OASISTSO10($e.GEO[0].POSITION.LOCID == “40005”)




instead of


                        OASISTSO10($e: EVENT)

                        OASISTSO10($e.GEO.POSITION.LOCID == “40005”)




Now I’m facing another problem. I need to check if the element GEO exists before checking the POSITION, otherwise it throws an outofbound exception.

I tried with:



                        OASISTSO10($e: EVENT)

                        EVENT($g: GEO)

                        OASISTSO10($e.GEO[0].POSITION.LOCID matches  "40.*")


But it doesn’t work. Any hints on this?


Thanks in advance,

Zaloa Otaduy del Paso

De: [] En nombre de David Sinclair
Enviado el: martes, 07 de octubre de 2008 15:58
Para: Rules Users List
Asunto: Re: RV: [rules-users] Checking an xml field


Read the manual man. Your rules don't make any sense

On Tue, Oct 7, 2008 at 9:49 AM, Scott Reed <> wrote:

What is the problem you are seeing? Do the rules compile ok?

Otaduy del Paso, Zaloa [10/6/2008 12:08 PM] wrote:

Does anybody know the answer to my question? I'm not able to solve this issue and don't find any clarifying tutorial either….




I'm new in drools and I'm having some problems accessing an xml field. I'm using drools with jaxb to treat xml files that follow an specific xsd. I have the following xml (this is just a piece of the xml):




<EVENT_ID>EVENT_ID_03/10/2008 10:22:36</EVENT_ID>























I already have a couple of rules working, but they are simple rules, like this one:


rule "Rule1"

    salience 10


                        OASISTSO10($e: EVENT)





The problem appears when I have to check the LOC_ID field and I don't know how to access to it. I have tried several things but none of them work





                        OASISTSO10($e.GEO.POSITION.LOCID == "40005")





OASISTSO10($g: $e.GEO)

                        OASISTSO10($p: $g.POSITION)

                        OASISTSO10($p.LOCID  == "40005")



I have also tried with ($e.GEO.POSITION.DESCRIPTION, just in case the "_" character was the problem. But the same results… I have searched also for examples with xmls but I haven't had luck.

Any help would be appreciated. Thanks in advance,





rules-users mailing list

rules-users mailing list



rules-users mailing list

_______________________________________________ rules-users mailing list