I think you need to either get rid of the space in "auto, kind" or change "," to ", " in your call to fn:tokenize(). fn:tokenize("auto, kind", ",") returns "auto" and " kind" (note leading space), so the second token matches nothing.
On Mon, Dec 8, 2014 at 1:48 PM, Danny Sokolsky <danny.sokol...@marklogic.com > wrote: > You already know how to do that. Just do something like this (passing a > sequence into a word-query treats each item as an or): > > let $s := (fn:tokenize("auto, kind", ",")) > let $doc := > <a> > <b id="car"> > <c xml:lang="en">car</c> > <c xml:lang="nl">auto</c> > <c xml:lang="fr">voiture</c> > </b> > <b id="house"> > <c xml:lang="en">house</c> > <c xml:lang="nl">huis</c> > <c xml:lang="fr">maison</c> > </b> > <b id= "child"> > <c xml:lang="en">child</c> > <c xml:lang="nl">kind</c> > <c xml:lang="fr">enfant</c> > </b> > </a> > return $doc//c[cts:contains(., cts:word-query($s, "lang=nl") )] > > -----Original Message----- > From: general-boun...@developer.marklogic.com [mailto: > general-boun...@developer.marklogic.com] On Behalf Of Frank Mortier > Sent: Monday, December 08, 2014 10:38 AM > To: MarkLogic Developer Discussion > Subject: Re: [MarkLogic Dev General] Marklogic node replace of same node > results in inconsistent output > > Thanks > > Danny, I need to get from the string ('auto, kind') to ('auto', 'kind'). > > Chris, it should return 'car' and 'child'. > > Tim, does not work, returns only the first id 'car' > > Rob, same answer as for Danny. > > > > > -----Original Message----- > From: general-boun...@developer.marklogic.com [mailto: > general-boun...@developer.marklogic.com] On Behalf Of Danny Sokolsky > Sent: 08 December 2014 19:15 > To: MarkLogic Developer Discussion > Subject: Re: [MarkLogic Dev General] Marklogic node replace of same node > results in inconsistent output > > Hi Frank, > > Or how about if you do a language-sensitive search. For example: > > let $doc := > <a> > <b id="car"> > <c xml:lang="en">car</c> > <c xml:lang="nl">auto</c> > <c xml:lang="fr">voiture</c> > </b> > <b id="house"> > <c xml:lang="en">house</c> > <c xml:lang="nl">huis</c> > <c xml:lang="fr">maison</c> > </b> > <b id= "child"> > <c xml:lang="en">child</c> > <c xml:lang="nl">kind</c> > <c xml:lang="fr">enfant</c> > </b> > </a> > return $doc//c[cts:contains(., cts:or-query(( > cts:word-query("auto", "lang=nl"), > cts:word-query("kind", "lang=nl"))) )] => <c > xml:lang="nl">auto</c> <c xml:lang="nl">kind</c> > > -Danny > > -----Original Message----- > From: general-boun...@developer.marklogic.com [mailto: > general-boun...@developer.marklogic.com] On Behalf Of Christopher Hamlin > Sent: Monday, December 08, 2014 10:14 AM > To: MarkLogic Developer Discussion > Subject: Re: [MarkLogic Dev General] Marklogic node replace of same node > results in inconsistent output > > Hi Frank, > > Not exactly sure if it's what you want, but maybe helps you get closer: > > for $x in $doc/b/c[@xml:lang eq"nl"] > where $x/fn:string() = fn:tokenize('auto, kind', ',') > return > $x/../@id/fn:string() > > returns 'car'. > > I changed it so it compares the string value of $x with a list of strings > from tokenize. Note that I'm using = instead of eq. That lets you use a > sequence compare. Also the return now returns the @id attribute node. > > - Chris > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general >
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general