All great ideas.
Question: What is the objection to if/else ?

-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]
Phone: +1 812-482-5224
Cell:  +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>


From: [email protected] 
[mailto:[email protected]] On Behalf Of Will Thompson
Sent: Monday, May 06, 2013 3:48 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Appropriate method to check multiple 
conditions in Marklogic 6

Sini - I use string-join() and concat() in these situations:

string-join(($address, $postcode/concat('-', .), $city/concat(' ', .)), '')

-Will

From: sini narayanan <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Discussion 
<[email protected]<mailto:[email protected]>>
Date: Monday, May 6, 2013 5:50 AM
To: MarkLogic Discussion 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Appropriate method to check multiple 
conditions in Marklogic 6

Hi All,

I have few documents in my database and each document have the following three 
tags,
address, postCode and city.

All the three tags will not have values in all the documents. Certain might 
have only address and some others only postCode and city.
In total it would result in 9 conditions(with all the permutation and 
combinations).

(All node have values, none have values, only city node has value, only address 
and postCode have value, etc...)


After all these condition checks, the final output I need is

concat(address,"-",postcode," ",city)

Here I need to pass by the seperating characters (- and space), if a field is 
empty. I.e: If address is absent then the output should start with the postCode 
and not "-". Similarly for all other cases.

Please tell me an appropriate method to use this other than if() else().


Thanks,
Sini
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to