Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 78983 invoked from network); 5 Jan 2007 18:31:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jan 2007 18:31:49 -0000 Received: (qmail 87746 invoked by uid 500); 5 Jan 2007 18:31:49 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 87698 invoked by uid 500); 5 Jan 2007 18:31:49 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 87687 invoked by uid 99); 5 Jan 2007 18:31:49 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jan 2007 10:31:49 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of rahul.akolkar@gmail.com designates 66.249.92.174 as permitted sender) Received: from [66.249.92.174] (HELO ug-out-1314.google.com) (66.249.92.174) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jan 2007 10:31:18 -0800 Received: by ug-out-1314.google.com with SMTP id s2so5685300uge for ; Fri, 05 Jan 2007 10:30:55 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=X2r1H9QS5jRlAdbuURhzdRqRlWk+ayCaLAv0KKA042LnF8ocPqAGD6GqqiZ/vrdvsPsDrH6J+PG/jO3YO1YM6Capg1I6f/kfFR/qbvN1kcCmNGinikwH8W284jsPtzG0R5mBC6CQwVaNw1vWwFH11lgLX9Qw433YKHrNSpxMcuw= Received: by 10.78.157.8 with SMTP id f8mr3161643hue.1168021854865; Fri, 05 Jan 2007 10:30:54 -0800 (PST) Received: by 10.78.165.12 with HTTP; Fri, 5 Jan 2007 10:30:54 -0800 (PST) Message-ID: Date: Fri, 5 Jan 2007 13:30:54 -0500 From: "Rahul Akolkar" To: "Jakarta Commons Users List" Subject: Re: [scxml] including chunks of scxml code. In-Reply-To: <20070105141754.55405.qmail@web50912.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070105141754.55405.qmail@web50912.mail.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org On 1/5/07, Nestor Urquiza wrote: > Hi, > I am sorry I could not reply before. Then, > No rush at all :-) > Using templating thru //state/@src is useful for > including reusable FSM as mean of whole states. > > XInclude/XML Entities are useful for including chunks > of SCXML logic. > > I am not sure how the first works but seems like > commons-scxml would parse just once those states > defined within the reusable FSM. For the second one I > think it complies with DRY principles, however since > including nodes means more processing for either SAX > or DOM parser I would predict some performance > degradation (the same in comparison to just copying > and pasting the bits within the main SCXML file > though). > Possibly, though its a one time cost (not per instance of state machine). > The question of course is if SCXML provides a way/tag > for real code reuse either templating or functions > that can be used "for any arbitrary bits or pieces". I > can read from [1] > The invoke tag is too heavyweight for the example below, and it is not completely fleshed out in the spec yet (as mentioned on Commons SCXML homepage). > Can anyone offer some snippet of code to solve let us > say the following simple example of code reuse? > > usecase: Build a template/function that returns the > name of the pet knowing that: > if animal type="dog" then name="Fido" > if animal type="cat" then name="Kitty" > if animal type="bird" then name="Tweety" > if animal type="horse" then name="Trigger" > if animal type="cat" then name="Tom" > if animal type="pig" then name="Porky" > if animal type="fish" then name="Charlie" > if animal type="pig" then name="Babe" > if animal type="cow" then name="Elsie" > if animal type="cat" then name="Puss" > > Of course using and it seems to be > possible to accomplish this but I am wondering if > someone already used them or simply someone can write > down the snippet of code that actually works while > using of course commons-scxml. > For such bits, define functions in your own namespace (see bottom of this page [A] ). The above pseudo could be the body of: public String petName(String species) { ... } whereby the name is obtained within executable content in the SCXML document as: (EL) (JEXL) This puts the procedural bits in a Java class, makes them reusable etc. -Rahul [A] http://jakarta.apache.org/commons/scxml/guide/contexts-evaluators.html > Thanks, > > -Nestor > > [1] http://www.w3.org/TR/scxml/ > > > --- Rahul Akolkar wrote: > > > On 11/1/06, Craig McClanahan > > wrote: > > > On 11/1/06, Nestor Urquiza > > wrote: > > > > > > > > Hello guys, > > > > > > > > I need to apply DRY ;-) so I do not want to be > > > > duplicating SCXML code that is to be included in > > many > > > > different states. > > > > > > > > Just wondering about the options we have here: > > > > > > > > 1)XInclude > > > > 2)A special tag from scxml??? > > > > 3) Any other idea? > > > > > > > > > XML entities? > > > > > > > > > This will work well for any abitrary bits and > > pieces, the earlier > > solution is just for s. But if you choose > > this, you'll have to > > worry about duplicating state IDs, if the bits and > > pieces contain > > those. > > > > -Rahul > > > > > > > Thanks, > > > > > > > > -Nestor > > > > > > > > > Craig > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org