on 02-06-2006 4:05 PM
Hi,
I have a question about Xpath handling with the XALAN package. My coding at present look like this:
CachedXPathAPI xp = new CachedXPathAPI();
NodeList t = = xp.eval(filterResult, stringExpression, pr).nodelist();
It workes fine but if the "stringExpression" do not match the nodelist t is null. Is there a possibility to figure out why the expression do not match.
I would like to print out an information like: "The XPathExpression do not match because value 'foo' do not exists in DOM".
It would be great if somebody has an idea how to do so.
cheers Mario
The question ist, how to get this Information. Fro example check wheater it contains e.g. a "@" when a null object is returned?
I think I can solve the problem when I am executing the expression in parts. First execute a common one and after that a more specific one...
But that is not an convenient way I think.
Thanks for your advice. I will post a solution when I have had time to solve the problem.
Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I understand your problem..See if the nodelist returned is null means it is obvious that the elements or attributes that u have given in the xpath do not exist...
Its very easy to know from xpath whether it is an attribute or element. If there is @ symbol in your xpath string then it will be an attribute, you just extract the name of attribute or element in the xpath String and try to print the corresponding message as required..I hope this will help you ..If not let me know.
Regards,
Sudheer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uma,
thanks for your reply. The Problem is not that my expression is incorrect in syntax. The XPath expression is correct at all.
I check with this expression e.g. if incoming messages contain expected nodes, attributes and values defined in my expression. So my xpath expression can be very complex...
The final goal is that I would like to know if it is possible to say witch kind (if it's a wrong value, a missing node or sth else) of dismatch appears.
Would be great to get some information about this.
regards Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mario,
Check whether your XPath stringExpression is in the format "/root/element1/sub-element1".
If 'foo' is the prefix for elements in XML, try to set this in PrefixResolver and use eval() method.
Hope this helps.
Regards,
Uma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.