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

Reply via email to