You just need to add a "return" before the "if", to make it into a
legal FLWOR statement.
-jh-
On Nov 11, 2009, at 12:18 PM, Srinivas Mandadapu wrote:
Thanks for the reply. It worked like a charm. On the same note I
have another question in Xquery in below snippet:
xquery version "1.0-ml";
import module namespace thsr="http://marklogic.com/xdmp/thesaurus"
at "/MarkLogic/thesaurus.xqy";
extractSynonyms("drugs")
declare function extractSynonyms($synTerm)
{
let $thsrEntry := thsr:lookup("/EBISynonyms/Synonyms.xml",
$synTerm)
if(!fn:empty($thsrEntry))
then $synTerm
else ""
};
Why is the code erroring out at conditional if statement!!? It seems
like a simple conditional statement to check whether any synonym
entries exist for the given term.
I appreciate your help.
Thanks,
Srini
Rix, Brad wrote:
A couple of things here,
You need to query for you elements in the thesaurus namespace.
declare namespace thesaurus = "http://marklogic.com/xdmp/thesaurus";
You also are already at the "entry" element when you defined the
variable $synEntry. Note, the query is now fn:count($synEntry/
thesaurus:synonym) (skip the entry and add the namespace).
Try the following:
xquery version "1.0-ml";
declare namespace thesaurus = "http://marklogic.com/xdmp/thesaurus";
let $synEntry := <entry xmlns="http://marklogic.com/xdmp/thesaurus">
<term>zinc</term>
<part-of-speech>noun</part-of-speech>
<qualifiers>
<qualifier>vicinity</qualifier>
</qualifiers>
<synonym>
<term>zinc chelate</term>
</synonym>
<synonym>
<term>zinc content</term>
</synonym>
<synonym>
<term>zinc dust</term>
</synonym>
<synonym>
<term>zinc isotopes</term>
</synonym>
<synonym>
<term>zinc radioisotopes</term>
</synonym>
<synonym>
<term>zinc retention</term>
</synonym>
<synonym>
<term>zincum</term>
</synonym>
<synonym>
<term>zn</term>
</synonym>
</entry>
let $synonymsCount := fn:count($synEntry/thesaurus:synonym)
return $synonymsCount
<ATT00001.gif>
Brad Rix
Senior Developer
+1 (303) 542-2172 | Office
+1 (303) 915-2771 | Mobile
brad....@flatironssolutions.com
http://www.flatironssolutions.com
IM: AIM: BradRix MSN: brad...@msn.com
From: general-boun...@developer.marklogic.com [mailto:general-
boun...@developer.marklogic.com] On Behalf Of Srinivas Mandadapu
Sent: Tuesday, November 10, 2009 9:29 AM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] question regarding a code snippet..
xquery version "1.0-ml";
let $synEntry := <entry xmlns="http://marklogic.com/xdmp/thesaurus">
<term>zinc</term>
<part-of-speech>noun</part-of-speech>
<qualifiers>
<qualifier>vicinity</qualifier>
</qualifiers>
<synonym>
<term>zinc chelate</term>
</synonym>
<synonym>
<term>zinc content</term>
</synonym>
<synonym>
<term>zinc dust</term>
</synonym>
<synonym>
<term>zinc isotopes</term>
</synonym>
<synonym>
<term>zinc radioisotopes</term>
</synonym>
<synonym>
<term>zinc retention</term>
</synonym>
<synonym>
<term>zincum</term>
</synonym>
<synonym>
<term>zn</term>
</synonym>
</entry>
let $synonymsCount := fn:count($synEntry/entry/synonym)
return $synonymsCount
The synonym count is coming out as "0" instead of "8"...still
couldn't figure out where I am going wrong.
I really appreciate if someone can help me on this.
Thanks,
Srini
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general