Discussion:
[MarkLogic Dev General] error message (err:XPTY0004) arg1 is not of type xs:string?
Hayden, William T
2014-01-29 17:48:03 UTC
Permalink
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
Mary Holstege
2014-01-29 17:56:24 UTC
Permalink
On Wed, 29 Jan 2014 09:48:03 -0800, Hayden, William T
Post by Hayden, William T
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
$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
Hayden, William T
2014-01-29 19:17:44 UTC
Permalink
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:***@marklogic.com]
Sent: Wednesday, January 29, 2014 12:56 PM
To: ***@developer.marklogic.com; Hayden, William T
Subject: Re: [MarkLogic Dev General] error message (err:XPTY0004) arg1 is not of type xs:string?
Post by Hayden, William T
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
$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
Gary Larsen
2014-01-29 19:29:46 UTC
Permalink
HI Bill,

Try adding this to the end of the query:

return $nothing

The result is false

Gary

-----Original Message-----
From: general-***@developer.marklogic.com [mailto:general-***@developer.marklogic.com] On Behalf Of Hayden, William T
Sent: Wednesday, January 29, 2014 2:18 PM
To: Mary Holstege; ***@developer.marklogic.com
Subject: Re: [MarkLogic Dev General] error message (err:XPTY0004) arg1 is not of type xs:string?

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:***@marklogic.com]
Sent: Wednesday, January 29, 2014 12:56 PM
To: ***@developer.marklogic.com; Hayden, William T
Subject: Re: [MarkLogic Dev General] error message (err:XPTY0004) arg1 is not of type xs:string?
Post by Hayden, William T
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
$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
Jakob Fix
2014-01-29 21:14:53 UTC
Permalink
<results warning="more than one root item">Nothing dog cat foo bar
cat</results>

as it says, it's not an actual error, but an indication that you're
apparently using the query console's XML output option to return non-XML.
As it's returning more than one item and none of them an XML element, the
query console wraps it in a root element to make it well-formed.

It seems that the query console has gotten cleverer with ML7 because it's
now offering only Auto and Raw as output options and I couldn't bring it to
generate the equivalent output.

so, just to say this is nothing to worry about.


cheers,
Jakob.


On Wed, Jan 29, 2014 at 8:17 PM, Hayden, William T <
Post by Hayden, William T
Thanks Mary. Like I said I have tried many options. The equality match
<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
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-----
Sent: Wednesday, January 29, 2014 12:56 PM
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 <
Post by Hayden, William T
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
$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
$file-type = $file-types
If you really mean fn:match, then you need
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
http://developer.marklogic.com/mailman/listinfo/general
Lien Suandy
2014-01-29 20:12:30 UTC
Permalink
this should do it

return if ($file-types = $file-type) then ... else ...


On Wed, Jan 29, 2014 at 12:48 PM, Hayden, William T <
Post by Hayden, William T
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
$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
http://developer.marklogic.com/mailman/listinfo/general
--
Lien H. Suandy
Software Application Development Engineer
(520) 955-8698
Marc Young
2014-01-29 20:23:18 UTC
Permalink
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)
)
Post by Lien Suandy
this should do it
return if ($file-types = $file-type) then ... else ...
On Wed, Jan 29, 2014 at 12:48 PM, Hayden, William T <
Post by Hayden, William T
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
$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
http://developer.marklogic.com/mailman/listinfo/general
--
Lien H. Suandy
Software Application Development Engineer
(520) 955-8698
_______________________________________________
General mailing list
http://developer.marklogic.com/mailman/listinfo/general
Marc Young
2014-01-29 20:25:35 UTC
Permalink
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.
Post by Hayden, William T
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)
)
Post by Lien Suandy
this should do it
return if ($file-types = $file-type) then ... else ...
On Wed, Jan 29, 2014 at 12:48 PM, Hayden, William T <
Post by Hayden, William T
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
$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
http://developer.marklogic.com/mailman/listinfo/general
--
Lien H. Suandy
Software Application Development Engineer
(520) 955-8698
_______________________________________________
General mailing list
http://developer.marklogic.com/mailman/listinfo/general
Lien Suandy
2014-01-29 21:02:14 UTC
Permalink
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>
Post by Marc Young
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.
Post by Hayden, William T
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)
)
Post by Lien Suandy
this should do it
return if ($file-types = $file-type) then ... else ...
On Wed, Jan 29, 2014 at 12:48 PM, Hayden, William T <
Post by Hayden, William T
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
$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
http://developer.marklogic.com/mailman/listinfo/general
--
Lien H. Suandy
Software Application Development Engineer
(520) 955-8698
_______________________________________________
General mailing list
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
http://developer.marklogic.com/mailman/listinfo/general
--
Lien H. Suandy
Software Application Development Engineer
(520) 955-8698
Hayden, William T
2014-01-30 03:32:49 UTC
Permalink
Thanks to everyone! I was able to get what I needed and learn a little more in the process. I appreciate all the options.

Thanks again,
Bill
Bill Hayden
Sent from blackberry


From: Jakob Fix [mailto:***@gmail.com]
Sent: Wednesday, January 29, 2014 04:14 PM
To: MarkLogic Developer Discussion <***@developer.marklogic.com>
Subject: Re: [MarkLogic Dev General] error message (err:XPTY0004) arg1 is not of type xs:string?

<results warning="more than one root item">Nothing dog cat foo bar cat</results>

as it says, it's not an actual error, but an indication that you're apparently using the query console's XML output option to return non-XML. As it's returning more than one item and none of them an XML element, the query console wraps it in a root element to make it well-formed.

It seems that the query console has gotten cleverer with ML7 because it's now offering only Auto and Raw as output options and I couldn't bring it to generate the equivalent output.

so, just to say this is nothing to worry about.


cheers,
Jakob.


On Wed, Jan 29, 2014 at 8:17 PM, Hayden, William T <***@boeing.com<mailto:***@boeing.com>> wrote:
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:***@marklogic.com<mailto:***@marklogic.com>]
Sent: Wednesday, January 29, 2014 12:56 PM
To: ***@developer.marklogic.com<mailto:***@developer.marklogic.com>; Hayden, William T
Subject: Re: [MarkLogic Dev General] error message (err:XPTY0004) arg1 is not of type xs:string?
Post by Hayden, William T
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
$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
***@developer.marklogic.com<mailto:***@developer.marklogic.com>
http://developer.marklogic.com/mailman/listinfo/general

Loading...