Reputation: 699
My code is working fine if I don't use function.
declare function local:samlefamily(
$pers as xs:string?) as xs:string?
{
some stuff
};
if (exists(/*/FamilyRec/Child/Link[@Ref = "IN0099"]))
then
for $family in doc("family.xml") /*/FamilyRec
where $family/Child/Link[@Ref = "IN0099"]
return if (local:samlefamily(data($family/HusbFath/Link/@Ref))) then local:samlefamily(data($family/HusbFath/Link/@Ref)) else "na1"
else "na2"
But problem occurs when I tried to define function
declare function local:giveParent($pers as xs:string) as xs:string
{if (exists(/*/FamilyRec/Child/Link[@Ref = $pers]))
then
for $family in doc("gedcom.xml") /*/FamilyRec
where $family/Child/Link[@Ref = $pers]
return if (local:samlefamily(data($family/HusbFath/Link/@Ref))) then local:samlefamily(data($family/HusbFath/Link/@Ref)) else "na1"
else "na2"
};
I am getting error: Description: Unexpected token "< eof >" in path expression
It is not occurring for passing parameter($pers). Even I use static ("IN0099") parameter to it, same error I am getting. Can anyone please help? Can't I use If ... else in user defined function? Advanced thanks for your support
Upvotes: 1
Views: 436
Reputation: 16917
You need to have at least one non-function statement in the xquery file, i.e. add anything after the last semicolon
Otherwise your code looks fine
Upvotes: 1