commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Pannier" <Steve_Pannier....@jacada.com>
Subject RE: [JXPath] Use of contexts/variables
Date Mon, 24 Feb 2003 22:52:10 GMT

Ed/Dmitri,

Thanks for clearing this up for me.  After playing around
with it a little and doing some testing, it looks like this will
work for us.


Steve Pannier
Jacada, Inc.
(763) 201-0002 Ext. 219
spannier@jacada.com
http://www.jacada.com


> Ed,
>
> I could not have said it better.  I am sorry I was not clear in my
> original response.
>
> Thanks,
>
> - Dmitri
>
> --- Ed Peters <ed.peters@webmethods.com> wrote:
> > Steve,
> >
> > If I understand you correctly, Dmitri's suggestion should work
> > perfectly for
> > you.  The Variables interface contains a method called "getVariable";
> > in
> > your case you would implement it to fetch objects out of this map
> > based on
> > their name.  For instance, in response to a call to
> >
> >  <your variables impl>.getVariable("Var1")
> >
> > You could simply return the value of Var1 (instead of a Map which the
> > user
> > would have to further dereference).
> >
> > Ed
> >
> > > -----Original Message-----
> > > From: Steve Pannier [mailto:Steve_Pannier.CST@jacada.com]
> > > Sent: Monday, February 24, 2003 11:55 AM
> > > To: Jakarta Commons Users List
> > > Subject: Re: [JXPath] Use of contexts/variables
> > >
> > >
> > >
> > > Dmitri,
> > >
> > > I'm not clear on how implementing the Variables interface
> > > can help us.
> > >
> > > I'm not sure I explained our situation well enough.  The data
> > > map we keep for our variables has a top level element whose
> > > key is the variable name.  For example, if the user's variable
> > > name is "Var1", then the top level element of that variable's
> > > data map is "Var1" also.  Since we need to allow access to
> > > any number of the user's variables in a single xpath expression,
> > > we decided to define each of their variables as JXPath
> > > variables, and add them to a NULL root context.  This is why
> > > the user must use $Var1/Var1/...." in their expression (the
> > > 1st "Var1" being the JXPath variable name, the 2nd one
> > > being the top level element of the map).  We would like them
> > > to only have to enter "$Var1" (or "/Var1") in their expression
> > > to reference everything below the top level element of the
> > > variable's data map.  That's why I was thinking we would
> > > need to pre-parse the expression itself and add in the "/Var1"
> > > for access to the top level element of the variable's map.  We
> > > do need them to specify the "Var1" in the expression so we
> > > know which variable's map they are referring to (their
> > > variables may contain like-named sub elements so we
> > > need a way to avoid name collisions - for example, we need
> > > to be able to differentiate between "Var1/count" and
> > > "Var2/count").
> > >
> > > If necessary, we can modify the JXPath code itself to implement
> > > this, but I was hoping there would be another way.  I've tried
> > > playing around with nested contexts, but with no luck so far.
> > >
> > > Anyway, I hope this is explains things better.  Let me know
> > > if implementing the Variables interface is still the way to
> > > accomplish this.
> > >
> > > Regards.
> > >
> > >
> > > Steve Pannier
> > > Jacada, Inc.
> > > (763) 201-0002 Ext. 219
> > > spannier@jacada.com
> > > http://www.jacada.com
> > >
> > >
> > > > Steve,
> > > >
> > > > This is an easy one.  In JXPath Variables is an interface - you
> > are
> > > > free to provide your own implementation and install it on
> > > JXPathContext
> > > > by calling context.setVariables().  It is a very simple
> > > interface and
> > > > you won't have any trouble meeting your requirement.
> > > >
> > > > I hope this helps.
> > > >
> > > > - Dmitri
> > > >
> > > >
> > > > --- Steve Pannier <Steve_Pannier.CST@jacada.com> wrote:
> > > > > Dmitri,
> > > > >
> > > > > Here's a new question for you.
> > > > >
> > > > > Our product allows the user to include any number of
> > > > > "variables" in their xpath expression.  These are not
> > > > > xpath variables, but rather variables they define in our
> > > > > design time framework.  The user is free to define the
> > > > > type for each variable, and they can define structure
> > > > > types.  Each variable's data is contained in a Map
> > > > > hidden in a subclass of the variable.  Now, when they
> > > > > provide an xpath expression, we allow them to include
> > > > > any number of these variables they choose to.  So, in
> > > > > order to allow us to evaluate these expressions without
> > > > > having to first parse the expression, we decided to create
> > > > > a root context of NULL, and then add each variable's
> > > > > data map to the context as an xpath variable.  The result
> > > > > of this is, if the user has a variable named "Var1", they
> > > > > must reference it in their expression as "$Var1/Var1".
> > > > >
> > > > > We would rather the user not have to use this syntax in
> > > > > expressions for referencing variables.  We are talking
> > > > > about allowing them to simply use "$Var1" in their
> > > > > expression.  Then before evaluating the expression we
> > > > > would substitute the "$Var1" with "$Var1/Var1".  This
> > > > > would require us to either write our own pre-parser, or
> > > > > somehow make use of JXPath code to do this.  But, I'm
> > > > > curious if there's any other way to attack this.  Maybe
> > > > > by defining the context differently.  Any ideas?
> > > > >
> > > > > Let me know if the above explanation of what we're
> > > > > trying to do is not clear.
> > > > >
> > > > >
> > > > > Steve Pannier
> > > > > Jacada, Inc.
> > > > > (763) 201-0002 Ext. 219
> > > > > spannier@jacada.com
> > > > > http://www.jacada.com
> > > > >
> > > > >
> > > > >
> > > > >
> > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail:
> > > commons-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> > > commons-user-help@jakarta.apache.org
> > > > >
> > > >
> > > >
> > > > __________________________________________________
> > > > Do you Yahoo!?
> > > > Yahoo! Tax Center - forms, calculators, tips, more
> > > > http://taxes.yahoo.com/
> > > >
> > > >
> > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > commons-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> > > commons-user-help@jakarta.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > commons-user-help@jakarta.apache.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>



Mime
View raw message