on 01-26-2009 7:23 PM
Hi everybody,
how can I check if an element in the payload is empty.
e.g. I got
<ELEMENT_TO_CHECK></ELEMENT_TO_CHECK>
or
<ELEMENT_TO_CHECK/>
I tested different variations of th XPATh-expression
string-length
. But found no solution.
Please post no assumptions. I would appreciate if you post answers which you have checked or already run.
Many thanks
Regards
Mario
Hi,
thank you all for your replies. Due to the priority of the problem, I had to find a workaround. So I implemented the workaround and could'nt check you suggestions! Sorry!
Many Regards Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mario,
string-length
It did not work for you because it will return "1" as a string length if the value is empty ([]), unlike your assumption that it will return length as "0".
"exists" will not work for you because it does not check the value inside the node but it checks if the node is present. so it will return true is the node is present (even if there is no value inside the node) and false if node is not present.
Now you comapre the node <ELEMENT_TO_CHECK> with constant and inside constant you give "[]".
and give it to equlas(text function) and then to if or ifwithoutElse (as per your requirment) .
if the value is empty it will return true else false.
this logic works for
<ELEMENT_TO_CHECK></ELEMENT_TO_CHECK>
or
<ELEMENT_TO_CHECK/>
(I have assumed that you want to do this validation in Message mapping and not in BPM)
Thanks,
Sunil Singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may compare the xpath expression with the blank string ' '.
Now i guess you must have tried this. So next think would be instead of providing the exact xpath, try using double slash and don't provide the root node name.
I could not test it and therefore it would be part of an assumpltion only.
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mario,
Anyway you are using xpath related expression, and therefore just additional double slash usage won't actually affect the performance much. Double slash simply means that it would take the first occurence of the specified field within the root node. It would hardly affect the performance by fraction of seconds.
Regards,
Prateek
hi,
did you try with EX (exists) ?
from help.sap.com
"Element exists in container or referenced element exists u2013 expression2 is not required."
Regards,
Michal Krawczyk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.