commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <rahul.akol...@gmail.com>
Subject Re: [SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions
Date Tue, 20 Oct 2009 22:42:10 GMT
On Tue, Oct 20, 2009 at 10:42 AM, Jaroslav Pullmann
<jaroslav.pullmann@fit.fraunhofer.de> wrote:
>
>  Dear Rahul, dear all,
>
>  the result value of an XPath-selection is limited to an XPathConstants.NODE
>  as of XPathEvaluator#evalLocation(Context, String). Having a root element
> is
>  reasonable for assignments etc. but I'd need to select a NodeSet based on
> the
>  XPath predicates first (and then wrap it evt. into a result element).
>
<snip/>

Right, the XPathEvaluator only supports types that it needs to fulfill
its contracts (generic expression, boolean or node result). Executing
an operation or task with arbitrary semantics requires either
extension functions or custom actions.


>  My use case resembles the form interpretation algorithm (FIA) of VXML: the
>  <datamodel> of a state is updated continually by the payload of arriving
> events
>  (inputs). There is an UI (form) which reflects the current datamodel and on
> each
>  change the remaining "empty" <data> items should be selected and presented
> for
>  completion:
>
> <state id="collectInput">
>        <datamodel>
>                <data id="statedata">...</data>
>                <data id="empty"><my:empty xmlns:my="urn:myns"/></data>
>        </datamodel>
>
>
>        <transition event="submit">
>
>                <!-- store input -->
>                <assign expr="$_eventdata/data"
> location="$statedata/dataitem[@id = $_eventdata/data/@id]"/>
>
>                <!-- test for remaining empty fields, wrap resulting NodeSet
> into "my:empty" element  -->
>                <assign expr="my:filter($statedata/item[. = ''],'my:empty')"
> location="$empty" />
>
>                <myfn:updateGUI/>
>
>        </transition>
>
>        <transition cond="count($empty/my:empty) = 0" target="nextInputState"
> />
>
>  </state>
>
>
>  Although the XPathEvaluator accpets XPathFunctions as constructor
> arguments,
>  there are no public accessors to the namespace and variable contexts. Could
> you
>  please provide an exmaple how to accomplish access to a data NodeSet using
> an
>  XPathFunction or an other way ?
>
<snap/>

You're correct that the namespace and variable contexts are not
trivially exposed to the functions and that is also sort of a thumb
rule on whether to use a function or an action.

I'd recommend using a custom action that captures these specific
semantics aiding behavior akin to the FIA, rather than having it
happen as a side-effect of a function invocation in an assignment
expression. IOW, if you have an action to the effect of the following
that has the behavior above:

  <myfn:assign nodeset="$statedata/item[. = '']" wrapper="my:empty"
location="$empty"/>

it (a) offers you access to the namespace and variable contexts, and
(b) models this separately from <assign> since it is indeed a
composite operation.

-Rahul


>  Many thanks !
>    Jaro
>
>
>
> --
> Jaroslav Pullmann
> Web Compliance Center - Fraunhofer FIT
> Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
> Phone: +49-2241-142623    Fax: +49-2241-142065
>

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


Mime
View raw message