commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dplot...@yahoo.com>
Subject Re: [JXPath] evaluating expression on a given node
Date Wed, 19 Feb 2003 15:40:40 GMT
Christian,

Let me see if I understand your requirement correctly.

You are reading an XML stream and building a custom data tree.  After
you have built a node of the tree you need to check if it meets some
condition.  If this is in fact what you are doing, JXPath should work
fine for you.

If the node is added to the tree before the condition is checked and
you know exactly where in the tree the new node is, you could get away
with one JXPathContext, e.g.:

   Boolean success = (Boolean)context.
      getValue("string-length(/employees[4]/addresses[2]/zipCode) =
5");

Otherwise you would have to create a new JXPathContext for each node:

   JXPathContext context = JXPathContext.newContext(node);
   Boolean success = (Boolean)context.
      getValue("string-length(street) <= 50");

In the latter case, especially if you need custom extension functions,
you might want to create a reusable base context. See
http://jakarta.apache.org/commons/jxpath/users-guide.html#Nested%20Contexts

I hope this helps.

- Dmitri

--- Christian Sell <christian.sell@netcologne.de> wrote:
> Hello,
> 
> I am intending to use XPath from inside an SAX DefaultHandler by 
> determining whether the current node conforms to a given expression.
> At 
> this point I have the node tree available in an application-specific 
> format which is built during parsing.
> 
> at first glance it seems to me that to do this I would have to delve 
> rather deep into the evaluation mechanism and adapt it to my purpose.
> 
> Does anyone have hints that may help me towards my purpose? Is JXPath
> 
> the right tool, or is there some other plaxe I should look to?
> 
> TIA,
> Christian
> 
> 
> ---------------------------------------------------------------------
> 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! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

Mime
View raw message