[xquery-talk] If Statements within an If Statement?

Wei, Alice J. ajwei at indiana.edu
Thu Apr 3 06:33:05 PST 2008


> That is exactly how I wanted it to read, although I am not sure how "white spaces" get in this picture.
>  The_tag,_maybe?

I'll show that string again but with space shown as _ and newline shown
as / so they are visible:


"/Send_10c_for_mailing_TODAY!/________________________________/Kenmore,_Mitford,_CR-272_N.H._03055//"


> I might have to try using declare boundary-space strip; Would this
> help?

It would make no difference in this case

You probably want to use

 distinct-values(normalize-space($seq))

and

$seq[normalize-space(.)=$d]

in which case the strings being compared would look like

"Send 10c for mailing TODAY! Kenmore, Mitford, CR-272 N.H. 03055"


I tried using this by changing the $sorted_result declaration to let

$sorted_result:=
for $doc in distinct-values(normalize-space($seq))
order by $doc

and do the similar thing like you suggested to the other lines

let $head := $seq[normalize-space(.)=$d][1]/ancestor::ad/descendant::head[1]
let $head2 := $seq[normalize-space(.)=$d][1]/ancestor::ad/descendant::head[2]
let $head3 := $seq[normalize-space(.)=$d][1]/ancestor::ad/descendant::head[3]
let $para := $seq[normalize-space(.)=$d][1]/ancestor::ad/descendant::p

This is what I got

The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: normalize-space($a as xs:string?) xs:string. Expected cardinality: zero or one, got 163.

Have I done something wrong?

Alice



More information about the talk mailing list