Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 25649 invoked from network); 23 Mar 2009 17:56:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Mar 2009 17:56:35 -0000 Received: (qmail 64748 invoked by uid 500); 23 Mar 2009 17:56:33 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 64639 invoked by uid 500); 23 Mar 2009 17:56:33 -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 64629 invoked by uid 99); 23 Mar 2009 17:56:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Mar 2009 17:56:33 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rahul.akolkar@gmail.com designates 209.85.198.243 as permitted sender) Received: from [209.85.198.243] (HELO rv-out-0506.google.com) (209.85.198.243) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Mar 2009 17:56:26 +0000 Received: by rv-out-0506.google.com with SMTP id k29so1118889rvb.2 for ; Mon, 23 Mar 2009 10:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=AV36Crsay7oevTNz40PrqgOj1A6ZujraSHn0a29Kb8k=; b=bXOC0sGvfTZN2r5nKF4Pfi0e3IVppBkspZeEKZmqjbXnqWaqoucrBBChj1AGlY4s+U 4ijv1bqv+ZgRGBp1Vkdy/ok7zRgpS11ihsgw/2sXEKHassNV68WzPBWQAOpz1Km3q418 4g3mtkko6meG3xMApZKw0IXPOM7gUl0bSppHs= 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=QRCClIngTBWmO11eYZeRVvgD5HdtgfkwKk6FRhPPt63n4jrTqCg4F9FHF+MIDb6Zxs anu+r/qfbJqcRGTpn9sUtM59at3FLiFA+KVY8NZGLrm23mIk5dMyaJ2v+oEEwcbHf8AA HLpPV9HiWk4R3nVO9L3iXBUIMPOp92up6m3Mw= MIME-Version: 1.0 Received: by 10.141.28.4 with SMTP id f4mr2414304rvj.37.1237830966286; Mon, 23 Mar 2009 10:56:06 -0700 (PDT) In-Reply-To: <49C78BB3.8050201@fit.fraunhofer.de> References: <49C78BB3.8050201@fit.fraunhofer.de> Date: Mon, 23 Mar 2009 13:56:06 -0400 Message-ID: Subject: Re: [SCXML] Test for node existence with Data() From: Rahul Akolkar To: Commons Users List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Mar 23, 2009 at 9:16 AM, Jaroslav Pullmann wrote: > > > =A0Hello, > > =A0while trying to test for the mere existence of a datamodel node it tur= ned > =A0out, that Data() yields to different results depending on the availabi= lity > =A0of an immediate textual content of the node: > > > =A01) Example, path does not match, Data() is expected to return null: > > =A0 null" /> > > =A0WARNING: Data(): No nodes matching the XPath expression > "objectList/object[@status =3D 1]", returning null > =A0INFO: NULL: false > =A0-> expected: true > IIRC, the reason for not returning null here is that the underlying EL will throw its own exception if further operations (such as the comparison above) are attempted on the null value. The type coercion rules used are aimed at allowing simple arithmetic operations (double, else long, else string) on leaf data nodes. > =A02) Example, same as 1) but tested with empty(), apparently an empty st= ring > is returned: > > =A0 /> > > =A0WARNING: Data(): No nodes matching the XPath expression > "objectList/object[@status =3D 1]", returning null > =A0INFO: NULL: true > Yup. > > =A03) Example, testing a container with no immediate textual content: > > =A0 > > =A0WARNING: Data(): Multiple nodes matching XPath expression > "objectList/object", returning first > =A0INFO: EMPTY: true > You are correct in pointing this out, however, as mentioned above the coercion rules were really designed for leaf data nodes (more on this below). > =A04) Example, testing a leaf element with immediate textual content: > > =A0 > > =A0WARNING: Data(): Multiple nodes matching XPath expression > "objectList/object/status", returning first > =A0INFO: EMPTY: false > Yes, as expected. > > =A0The method apparently invoked in this context: Object > org.apache.commons.scxml.Builtin#data() > =A0calls SCXMLHelper#getNodeValue() to retrieve a textual representation = of > the node. This is done > =A0at the level of immediate child nodes, which themselves are not proces= sed > recursively. According > =A0to 1) and 3) there seems to be no test to distiguish whether a node is > missing at all or it has > =A0element only content. For the former I'd expect null as return value, At the time the decision was made, the general philosophy to avoid EL blow ups as noted above made sense. > for > the latter all text nodes > =A0concatenated in a deep frist traversal of all child nodes ? Possibly. We've generally tried to discourage checking values of anything other than leaf data nodes i.e. given the proposal, the following s will be coerced to the same value, which is differently strange :-) A B A B -Rahul > > =A0 Thank you > =A0 =A0 Jaro > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org