Thanks Mary.  Like I said I have tried many options.  The equality match 
options yields the following errored results without an actual error: <results 
warning="more than one root item">Nothing dog cat foo bar cat</results>

I haven’t tried running a loop until now and this is what I'm getting"

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
            else
            (
            
            )

  :)
let $nothing :=
    fn:empty(
    for $f in $file-types return
       if (fn:matches($f, $file-type)) then "ok" else ())
+++++++++++++++++++++++++++
Results
+++++++++++++++++++++++++++
[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, 
unexpected $end

Stack Trace
At line 18 column 57:

16. fn:empty(
17. for $f in $file-types return
18. if (fn:matches($f, $file-type)) then "ok" else ())
19.

I know it is something simple, this is one of those cases where for some 
reason, I just don't see it!

Thanks
bill

-----Original Message-----
From: Mary Holstege [mailto:[email protected]] 
Sent: Wednesday, January 29, 2014 12:56 PM
To: [email protected]; Hayden, William T
Subject: Re: [MarkLogic Dev General] error message (err:XPTY0004) arg1 is not 
of type xs:string?

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