Dmitri Plotnikov wrote:
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.
that sounds like a good descriptions of my problem, indeeed
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");
that is not feasible, as I want to be able to evaluate for an arbitrary
node inside the tree, and I cannot control the expression being provided.
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 am not getting this. Why would I create new contexts, and where would
I keep them? What context do I hand the expression to?Let me try to explain my issue once again:
I have an expression that is provided externally (by the user), which states, for example "every 'book' node which has a 'category' child node containing the text 'fiction' shall be colored in red". Now, while I am processing the XML document, I want to determine for each node whether it meets the condition.
More conditions:
- the data tree objects do not conform to the JavaBean spec. I have to use custom code to determine their properties
- I dont want to parse the XML document or the XPath expression more than once.
thanks,
Christian
BTW, any hints on how to build JXPath from cvs? I am getting lots of test failures, and maven.log is full of error messages about invalid uses of Jelly tags.
I hope this helps. - Dmitri --- Christian Sell <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
__________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
