Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 45325 invoked from network); 11 Aug 2010 21:05:10 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Aug 2010 21:05:10 -0000 Received: (qmail 56530 invoked by uid 500); 11 Aug 2010 21:05:09 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 56453 invoked by uid 500); 11 Aug 2010 21:05:08 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 56443 invoked by uid 99); 11 Aug 2010 21:05:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Aug 2010 21:05:08 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rahul.akolkar@gmail.com designates 74.125.82.171 as permitted sender) Received: from [74.125.82.171] (HELO mail-wy0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Aug 2010 21:05:03 +0000 Received: by wyb29 with SMTP id 29so550565wyb.30 for ; Wed, 11 Aug 2010 14:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=luagFSxtl/qE81ajt4GozeY71G/WooAKqdFtQiivUxQ=; b=jbJWRAOCethzny+qqB4JbVBiKQZ64r9/oqjY18pOJYHJtUlLStQxd+f+V5KPbUQiIU 5IR37hVKY7GUftcTaCRxfjaTTBRwlPJ1crwmmW4e8Z4LSeTt+URTVsN37byk47uJBA8w imKaAwyLGVgYEtEa8KC7+i2CCDkGdzObSKmDY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=tLiNFztMtkusqIEKvGY82hRKtxNMN1qNOJVnEzNrfiROnL6FDEC1gJT2jQQWP8Tdkh n41j6NBgBBMBX6Z9y0Ag6ePqB+XmJL0WZ+NWj03bVTZe1YLmo/XGcoyiPdrOQBVgbk5i zCLul6aONwluGd8luKzRddZCI957+DEm+4DZw= MIME-Version: 1.0 Received: by 10.227.69.134 with SMTP id z6mr16874127wbi.201.1281560681752; Wed, 11 Aug 2010 14:04:41 -0700 (PDT) Received: by 10.227.155.195 with HTTP; Wed, 11 Aug 2010 14:04:41 -0700 (PDT) In-Reply-To: <4C62FF4E.3030800@mitre.org> References: <4C61DCBE.8020400@mitre.org> <4C62E9B9.8000007@mitre.org> <4C62FF4E.3030800@mitre.org> Date: Wed, 11 Aug 2010 17:04:41 -0400 Message-ID: Subject: Re: [scxml] datamodel, custom actions and digester From: Rahul Akolkar To: Commons Users List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Aug 11, 2010 at 3:51 PM, Abigail Gertner wrote: > > > On 8/11/2010 3:36 PM, Rahul Akolkar wrote: >> On Wed, Aug 11, 2010 at 2:19 PM, Abigail Gertner wro= te: >> >>> >>> On 8/11/2010 12:29 AM, Rahul Akolkar wrote: >>> >>>> >>>> The way to obtain the live values of the datamodel is to use the >>>> expression evaluator, see interfaces mentioned here: >>>> >>>> =A0 http://commons.apache.org/scxml/guide/contexts-evaluators.html >>>> >>>> >>>> >>> Is it possible to call a method using the expression evaluator with an >>> argument that is a node in the XML tree, rather than just a string valu= e? >>> >>> >> >> >> Executable content is open ended in SCXML, as largely speaking most >> things are possible with custom actions. I'm afraid I've lost the >> bigger picture of your scenario in the pin-pointed question above. >> >> To obtain a node using the expression evaluator, use >> Evaluator#evalLocation(...) which returns a Node. >> > > What I mean is, if I want to do something like: > > > =A0 > > > Where the argument to foo.bar() is a Node from the datamodel, but with > the current context values included, how can I get that from the > expression evaluator. I tried using the Data('var','path') expression > but it doesn't seem to work for nodes. > Here are some ways to tackle this: * Break the above into smaller operations: (1) obtain a node, (2) invoke the method. For example: =A0 where uses Evaluator#evalLocation(...) and creates a "var" matching the name argument. * Use XPath as the expression language as its better equipped to deal with XML nodes. The above would then become: =A0 However, the XPath evaluator isn't available in the latest release however, but rather in a branch: http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/src/mai= n/java/org/apache/commons/scxml/env/xpath/ * A bit of background - The Data() function is mostly limited to values of leaf nodes (strings, integers) and is designed to satisfy the rvalue of most assignment expressions. There is a corresponding LData() -- I presume you're using JEXL -- that is meant to satisfy the lvalue (and will return nodes) but these are implementation details so resorting to using LData isn't recommended. >>>> Might be worthwhile revisiting the need for using >>>> SCXMLParser#newInstance() rather than the static parse methods. >>>> >>>> >>>> >>>> >>> The reason I am doing this is that I am using xinclude to include a >>> separate xml file and I found that I needed to call setXIncludeAware() >>> on the parser to make it do the include. Is there some way to do this >>> using the static parse methods? >>> >>> >> >> >> Not in the latest release (v0.9) so thats one of the cases where you >> may indeed not be able to use the static parse methods. Based on what >> I've read so far, it seems your best bet may be to register the >> digester rules for your custom actions by hand after you obtain the >> new instance and let the custom action do the appropriate expression >> evaluation and datamodel / context processing. >> > I'm trying to do it this way now and having trouble getting the custom > action to fire. I am using > > dig.addObjectCreate("!*/onentry/sendMessage", SendMessage.class); > > Where my custom action is called SendMessage. > > Then in my scxml file I have > > > =A0 > > > The SendMessage object is being created when the file is parsed, but the > execute() method is not being called when the state is entered. > Do I have to do something else to get it to call execute()? > Minimally, you'll have to add the SetNextRule (and maybe others, as per your action needs), so this: dig.addSetNext("!*/onentry/sendMessage", "addAction"); Also, best to use a different XML namespace for custom actions. See Digester#setRuleNamespaceURI(...) for this purpose. -Rahul --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org