RV: [rules-users] Checking an xml field

Scott Reed sreed at avacoda.com
Tue Oct 7 12:55:45 EDT 2008


Yes, my suggestion would need to use the access methods (e.g. getGEO()) 
but I don't know what their names are.

Otaduy del Paso, Zaloa [10/7/2008 12:38 PM] wrote:
>
> Hi,
>
>  
>
> I have tried
>
> OASISTSO10($e: EVENT)
>
>                         EVENT($g: $e.GEO[0])
>
>                         OASISTSO10($e.GEO[0].POSITION.LOCID matches  
> "40.*")
>
>  
>
> It makes sense to me, since
>
> OASISTSO10($e: EVENT)
>
>                         OASISTSO10($e.GEO[0].POSITION.LOCID matches  
> "40.*")
>
>  
>
> Is working and what I want to check is the field GEO from $e. The 
> issue is that doing what you suggested (the first code lines) I get 
> the following error:
>
>  
>
> org.drools.rule.InvalidRulePackage: Unable to create Field Extractor 
> for '$e.GEO[0]' : [Rule name=DistribuirPorProvincia2, 
> agendaGroup=MAIN, salience=2, no-loop=false]
>
> _org.drools.RuntimeDroolsException_: 
> _org.drools.RuntimeDroolsException_: 
> _org.drools.RuntimeDroolsException_: Field/method '$e' not found for 
> class 'es.indra.simge.businessrules.jaxb.tso.EVENT'
>
>       at org.drools.rule.Package.checkValidity(_Package.java:424_)
>
>  
>
> I have also tried Scott's suggestion:
>
> OASISTSO10($e: EVENT)
>
>                         eval($e.GEO[0].POSITION.LOCID.equals("40005"))
>
>  
>
> but I also get the compilation error:
>
>  
>
> org.drools.rule.InvalidRulePackage: Rule Compilation error : [Rule 
> name=DistribuirPorProvincia2, agendaGroup=MAIN, salience=2, no-loop=false]
>
>       
> es/indra/simge/businessrules/jaxb/tso/Rule_DistribuirPorProvincia2_0.java 
> (9:441) : $e.GEO cannot be resolved or is not a field
>
>       at org.drools.rule.Package.checkValidity(_Package.java:424_)
>
>  
>
> I'm pretty confused because sometimes the $e is recognized as an 
> event, the rules I already have work, but in other cases the 
> $e./FIELD/ returns a compilation error.
>
>  
>
>  
>
> *Zaloa Otaduy del Paso*
> Consultoría Tecnológica
>
> ------------------------------------------------------------------------
>
> *De:* rules-users-bounces at lists.jboss.org 
> [mailto:rules-users-bounces at lists.jboss.org] *En nombre de *Knapp, Barry
> *Enviado el:* martes, 07 de octubre de 2008 18:17
> *Para:* Rules Users List
> *Asunto:* RE: RV: [rules-users] Checking an xml field
>
>  
>
> Might be worth trying
>
>  
>
> OASISTSO10($e: EVENT)
>
>                         EVENT($g: $e.GEO[0])
>
>                         OASISTSO10($e.GEO[0].POSITION.LOCID matches  
> "40.*")
>
>  
>
> Barry
>
>  
>
>  
>
> *From:* rules-users-bounces at lists.jboss.org 
> [mailto:rules-users-bounces at lists.jboss.org] *On Behalf Of *Otaduy del 
> Paso, Zaloa
> *Sent:* Tuesday, October 07, 2008 11:23 AM
> *To:* Rules Users List
> *Subject:* RE: RV: [rules-users] Checking an xml field
>
>  
>
> 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
>
>  
>
> when
>
>                         OASISTSO10($e: EVENT)
>
>                         OASISTSO10($e.*GEO[0].*POSITION.LOCID == "40005")
>
>             Then
>
>                         Action
>
>  
>
> instead of
>
>             when
>
>                         OASISTSO10($e: EVENT)
>
>                         OASISTSO10($e.GEO.POSITION.LOCID == "40005")
>
>             Then
>
>                         Action
>
>  
>
> 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:
>
>  
>
>  when
>
>                         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:* rules-users-bounces at lists.jboss.org 
> [mailto:rules-users-bounces at lists.jboss.org] *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
>
> http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/
>
> On Tue, Oct 7, 2008 at 9:49 AM, Scott Reed <sreed at avacoda.com 
> <mailto:sreed at avacoda.com>> 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....
>
>  
>
> Hi,
>
>  
>
> 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):
>
>  
>
> <OASIS_TSO_1_0>
>
>       <EVENT>
>
> <EVENT_ID>EVENT_ID_03/10/2008 10:22:36</EVENT_ID>
>
> <NODE_ID>00</NODE_ID>
>
> <OTHER_EVENT_ID>Incidente UME</OTHER_EVENT_ID>
>
> <EVENT_TYPE>POL</EVENT_TYPE>
>
> <SOURCE>HUMDED</SOURCE>
>
> <SEVERITY>EXTREM</SEVERITY>
>
> <CERTAINTY>88</CERTAINTY>
>
> <DECL_DATIME>2008-10-03T10:20:47.0000000+02:00</DECL_DATIME>
>
> <GEO>
>
> <DESCRIPTION/>
>
> <POSITION>
>
> <LOC_ID>14021</LOC_ID>
>
> <COORD>
>
> <LAT>37.9811636567434</LAT>
>
> <LON>-4.85417587343286</LON>
>
> <HEIGHT>0</HEIGHT>
>
> </COORD>
>
> </POSITION>
>
> </GEO>
>
>      </EVENT>
>
> </OASIS_TSO_1_0>
>
>  
>
>  
>
> I already have a couple of rules working, but they are simple rules, 
> like this one:
>
>  
>
> rule "Rule1"
>
>     salience 10
>
> when
>
>                         OASISTSO10($e: EVENT)
>
> OASISTSO10($e.SEVERITY == "EXTREM") or OASISTSO10($e.SEVERITY == "SEVERE")
>
>             then
>
>                         action
>
>  
>
> 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
>
>  
>
> 1.
>
>             when
>
> OASISTSO10($e: EVENT)
>
>                         OASISTSO10($e.GEO.POSITION.LOCID == "40005")
>
>             then
>
> 2.
>
>             when
>
> OASISTSO10($e: EVENT)
>
> OASISTSO10($g: $e.GEO)
>
>                         OASISTSO10($p: $g.POSITION)
>
>                         OASISTSO10($p.LOCID  == "40005")
>
>             Then
>
>  
>
> 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,
>
>  
>
> Zaloa
>
>  
>
>  
>  
>  
>  
>
>
> ------------------------------------------------------------------------
>
>
>  
>  
>  
>  
>  
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>  
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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/20081007/b5b21bbe/attachment.html 


More information about the rules-users mailing list