On Wed, 29 Jan 2014 09:48:03 -0800, 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
>

fn:matches wants there to be a single value a the
first argument: it is a regular expression match of
one value against one regular expression.

If you are just doing an equality match you can
use the "=" operator (which will operate over
sequences and return true if any member is
equal:

$file-type = $file-types

If you really mean fn:match, then you need
to run the loop yourself:

let $nothing :=
    fn:empty(
    for $f in $file-types return
       if (fn:matches($f, $file-type)) then "ok" else ())

If there is any match the sequence given to fn:empty
will be non-empty so $nothing is false.

//Mary
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to