string treated as sequence

Having trouble installing Oxygen? Got a bug to report? Post it all here.
sandrocchio_0.1
Posts: 14
Joined: Tue Nov 23, 2010 4:04 pm

string treated as sequence

Post by sandrocchio_0.1 »

I've got this function which is giving me some strange errors during debug.
xquery.xq
Severity: fatal
Description: A sequence of more than one item is not allowed as the first argument of string-length() ("Abonnement...", "film...", ...)
Start location: 315:0
URL: http://www.w3.org/TR/xpath20/#ERRXPTY0004
Either the parameters and return value are raw string, so why is treating them as sequence?

Code: Select all


declare function local:normalizeSourceHelper(
$sourceString as xs:string,
$compareString as xs:string)
as xs:string* {
let $result :=
let $arraySource := tokenize($sourceString, ";")
let $arraycompare := tokenize($compareString, ";")
for $source in $arraySource
where $source != ""
return
if(count(
for $compare in $arraycompare
where $compare = $source return (1))=0 )
then concat(data($source), ";")
else
""
return
if(string-length($result)>0) then common:removeLastSemiColumnChar($result)
else $result
};
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: string treated as sequence

Post by adrian »

Hello,

The error complains about the argument of string-length() being a sequence. The argument is $result. Now look at the value assigned to $result:

Code: Select all

let $result :=
let $arraySource := tokenize($sourceString, ";")
let $arraycompare := tokenize($compareString, ";")
for $source in $arraySource
where $source != ""
return
if(count(
for $compare in $arraycompare
where $compare = $source return (1))=0 )
then concat(data($source), ";")
else
""
It's the result of a for which creates a sequence. Ir may be a sequence of strings, but it's still a sequence, hence the problem.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sandrocchio_0.1
Posts: 14
Joined: Tue Nov 23, 2010 4:04 pm

Re: string treated as sequence

Post by sandrocchio_0.1 »

thanks!
Post Reply