commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jaroslav Pullmann <jaroslav.pullm...@fit.fraunhofer.de>
Subject [SCXML] Test for node existence with Data()
Date Mon, 23 Mar 2009 13:16:35 GMT


   Hello,

  while trying to test for the mere existence of a datamodel node it turned
  out, that Data() yields to different results depending on the availability
  of an immediate textual content of the node:


   1) Example, path does not match, Data() is expected to return null:

   <log label="NULL" expr="Data(data,'objectList/object[@status = 1]') == null" />

   WARNING: Data(): No nodes matching the XPath expression "objectList/object[@status = 1]",
returning null
   INFO: NULL: false
   -> expected: true

   2) Example, same as 1) but tested with empty(), apparently an empty string is returned:

   <log label="NULL" expr="empty(Data(data,'objectList/object[@status = 1]'))" />

   WARNING: Data(): No nodes matching the XPath expression "objectList/object[@status = 1]",
returning null
   INFO: NULL: true


   3) Example, testing a container with no immediate textual content:

   <log label="EMPTY" expr="empty(Data(data,'objectList/object'))" />

   WARNING: Data(): Multiple nodes matching XPath expression "objectList/object", returning
first
   INFO: EMPTY: true

   4) Example, testing a leaf element with immediate textual content:

   <log label="EMPTY" expr="empty(Data(data,'objectList/object/status'))" />

   WARNING: Data(): Multiple nodes matching XPath expression "objectList/object/status", returning
first
   INFO: EMPTY: false


   The method apparently invoked in this context: Object org.apache.commons.scxml.Builtin#data()
   calls SCXMLHelper#getNodeValue() to retrieve a textual representation of the node. This
is done
   at the level of immediate child nodes, which themselves are not processed recursively.
According
   to 1) and 3) there seems to be no test to distiguish whether a node is missing at all or
it has
   element only content. For the former I'd expect null as return value, for the latter all
text nodes
   concatenated in a deep frist traversal of all child nodes ?

    Thank you
      Jaro

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message