|
next
|
 Subject: Help with another DataDirect processor error Author: Kam Chan Date: 08 Jul 2009 03:06 PM Originally Posted: 08 Jul 2009 03:05 PM
|
Hi,
I am having another problem with DataDirect processor.
When running the xQuery, the function below encounters this error:
[err:XPTY0004]Static type error. Type 'element(*, xs:anyType)*' is not valid for argument 1 of function 'functx:last-node'. Required type is 'element(*, xs:untyped)*'. [Call stack: laforms:CA04130807-impl@116.11, commonvars:getNamedInsured@62.64, fn:string@50.26, fn:node-name@50.33, functx:last-node@50.43]
declare function commonvars:getNamedInsured($system as element()) as xs:string
{
let $_insured := functx:first-node($system/PolicyInsured),
$insuredNm := if(string(node-name(functx:last-node($_insured/element()[Id/text() = $_insured/InsuredId/text()]))) = "Company") then
functx:last-node($_insured//Company[Id/text() = $_insured/InsuredId/text()])/Name/text()
else commonfunc:get-human-name(functx:last-node($_insured//Human[Id/text() = $_insured[(Type/text() = "NamedInsured") and (string(@offset) != "Deleted")]/InsuredId/text()]))
return $insuredNm
};
I don't understand why can't "anyType" be converted to "untyped" automatically. And I don't understand why the xPath doesn't return the correct type that is compatible with these functions. And finally, these same lines of code exists and executed in the same problem, but just in the main program body. I don't understand why that works there (in the same program run), and not in this function.
Any help with resolving this and the explanations for me to understand with many other DataDirect type-checking issues, is much appreciated.
Thanks
Kam
|
next
|
 Subject: Help with another DataDirect processor error Author: Kam Chan Date: 09 Jul 2009 09:13 AM
|
Hi Ivan,
The call to getNamedInsured() from laforms:CA04130807-impl:
{ commonfunc:populate-variable-by-string("NAMED_INSURED", commonvars:getNamedInsured($system)) }
which is called from laforms:CA04130807():
laforms:CA04130807-impl($system, $allFormsWithoutDetails, (), $requestId, 0)
which is called from the main module:
laforms:CA04130807($system, $f, $formReqId)
The main module declared the $system as follows:
declare variable $xPRSXMLInput as document-node(element(*, xs:untyped)) external;
declare variable $system := $xPRSXMLInput/AscendantOne/Policy;
The $system variable was just passed from function to function, with no re-definition.
As I mentioned initially, the main module contains pretty much the identical code, but it doesn't have a problem:
declare variable $_insured := functx:first-node($system/PolicyInsured);
declare variable $insuredNm := if(string(node-name(functx:last-node($_insured/node()[Id/text() = $_insured/InsuredId/text()]))) = "Company") then functx:last-node($_insured//Company[Id/text() = $_insured/InsuredId/text()])/Name/text()
else commonfunc:get-human-name(functx:last-node($_insured//Human[Id/text() = $_insured[(Type/text() = "NamedInsured") and (string(@offset) != "Deleted")]/InsuredId/text()]));
And, strangely, getNamedInsured() is called identically from may be another 30 functions (those form functions), and they don't seem to have problems. At least they don't have problems before, because right now if I comment out this function (laforms:CA04130807), I am not getting this Static Type error when they are called from other form functions, but getting the hated NullPointerException.
Thanks
Kam
|
|
|
|