Marc,

The = operator will compare sequences of more than one value. It returns
true if just one value is found in the sequence.

xquery version "1.0-ml";
declare variable $file-types := ("dog","cat","foo","bar");

let $file-type := "cat"
return ($file-type = $file-types)

====>
<?xml version="1.0" encoding="UTF-8"?>
<results warning="atomic item">true</results>


If you're coming values between 2 sequences if just one value in one is
found in the other, if evaluates to true. So,

xquery version "1.0-ml";
declare variable $file-types := ("dog","cat","foo","bar");

let $file-type := ("just", "cat", "some", "list", "of", "words")
return ($file-type eq $file-types)

====> also returns true
<?xml version="1.0" encoding="UTF-8"?>
<results warning="atomic item">true</results>






On Wed, Jan 29, 2014 at 3:25 PM, Marc Young <[email protected]> wrote:

> fn:matches is a text match. It doesn't accept a sequence. You'd use it for
> checking if 'cat' appeared in the word 'catastrophe'. As for Liens
> response, that's not exactly true, you'd want to make sure the item appears
> IN the sequence, not that it matches the sequence. Index-of will return
> either an index of a match, or an empty sequence, so you can use the return
> value for a true/false match.
>
>
> On Wed, Jan 29, 2014 at 2:23 PM, Marc Young <[email protected]> wrote:
>
>> xquery version "1.0-ml";
>> declare namespace html = "http://www.w3.org/1999/xhtml";;
>>
>> declare variable $file-types := ("dog","cat","foo","bar");
>>
>> let $file-type := ("cat")
>>
>> return
>>   if (fn:index-of($file-types, $file-type)) then (
>>     ("Item is in the sequence", $file-types, $file-type)
>>   ) else (
>>     ("Item is NOT in the sequence", $file-types, $file-type)
>>   )
>>
>>
>> On Wed, Jan 29, 2014 at 2:12 PM, Lien Suandy <[email protected]> wrote:
>>
>>> this should do it
>>>
>>>  return if ($file-types = $file-type) then ... else ...
>>>
>>>
>>> On Wed, Jan 29, 2014 at 12:48 PM, Hayden, William T <
>>> [email protected]> wrote:
>>>
>>>>  Perhaps one of you can see the error of my ways.  I have tried so
>>>> many options with no success.  I am using ML5.  Here is the latest
>>>> simplified version  followed by the failing results.
>>>>
>>>>
>>>>
>>>> Thanks in advance!
>>>>
>>>>
>>>>
>>>> xquery version "1.0-ml";
>>>>
>>>> declare namespace html = "http://www.w3.org/1999/xhtml";;
>>>>
>>>> declare variable $file-types := ("dog","cat","foo","bar");
>>>>
>>>>
>>>>
>>>> let $file-type := ("cat")
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>     return if (fn:matches($file-types, $file-type)) then
>>>>
>>>>                    ("Nothing", $file-types, $file-type)
>>>>
>>>>         else
>>>>
>>>>         (
>>>>
>>>>
>>>>
>>>>         )
>>>>
>>>> +++++++++++++++++++++++++++
>>>>
>>>> Results
>>>>
>>>> +++++++++++++++++++++++++++
>>>> [1.0-ml] XDMP-ARGTYPE: (err:XPTY0004) fn:matches(("dog", "cat", "foo",
>>>> ...), "cat") -- arg1 is not of type xs:string? Stack Trace At line 8
>>>> column 15:
>>>>
>>>> $file-type := "cat"
>>>>
>>>> 6.
>>>> 7.
>>>> 8. return if (fn:matches($file-types, $file-type)) then
>>>> 9. ("Nothing", $file-types, $file-type)
>>>> 10. else
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> http://developer.marklogic.com/mailman/listinfo/general
>>>>
>>>>
>>>
>>>
>>> --
>>> Lien H. Suandy
>>> Software Application Development Engineer
>>> (520) 955-8698
>>>
>>>
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>>
>>>
>>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
>


-- 
Lien H. Suandy
Software Application Development Engineer
(520) 955-8698
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to