[MarkLogic Dev General] Appropriate method to check multiple conditions in Marklogic 6

David Lee David.Lee at marklogic.com
Mon May 6 12:51:07 PDT 2013


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

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


From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] 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 <sini.isonline at gmail.com<mailto:sini.isonline at gmail.com>>
Reply-To: MarkLogic Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Monday, May 6, 2013 5:50 AM
To: MarkLogic Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20130506/a0b6f7fc/attachment.html 


More information about the General mailing list