Reputation: 1405
So I'm trying to save my SOAP Response to a db using xpath expressions like
...#[xpath('//Person/Name/Firstname').text], #[xpath('//Person/Name/Lastname').text],
#xpath('//Relations/Relation/RelationId/Id').text], #xpath('//Relations/Relation/Relationtype').text])).....
But I wonder how to handle the "Relation" element. It is optional, and if it exists it can exist several times and the elements can have different names depending of type of Relation. If it exists I always want to save all of it so I wonder what the best way is to handle this?
Regards
EDIT
If the element "Relations" exists, it can have one or several "Relation" element and subelements with different names. I'm not sure how to handle it, maybe its best to use a ChoiceRouter first to check if "Relations" exist. If it does I'll need to have a "foreach" and then do huge amount of checks to see which subelements are there so I could save them all to the database.
Upvotes: 0
Views: 185
Reputation: 8311
You could use ternary expression for if/else in a single MEL expression for your reference .. check pls this :- http://mvel.codehaus.org/MVEL+2.0+Control+Flow
for example the following checks the Relation element and if exists, it extracts //Relations/Relation/RelationId/Id
or put your else condition and return node.text... you can modify as per your requirement :-
#[node = xpath('//Relations/Relation') != null ? xpath('//Relations/Relation/RelationId/Id').text : your else condition;node.text;]
Upvotes: 1