XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Kam ChanSubject: 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

Postnext
Ivan PedruzziSubject: Help with another DataDirect processor error
Author: Ivan Pedruzzi
Date: 09 Jul 2009 12:51 AM

Could you please show us which XPath expression you are passing to getNamedInsure?

Thanks!
Ivan Pedruzzi
Stylus Studio Team

Postnext
Kam ChanSubject: 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

Postnext
Ivan PedruzziSubject: Help with another DataDirect processor error
Author: Ivan Pedruzzi
Date: 09 Jul 2009 03:37 PM

Can you show us the full prototype definitions for all the functions in the callstack

- laforms:CA04130807()
- laforms:CA04130807-impl
- commonvars:getNamedInsured()


Thanks!
Ivan

Posttop
Kam ChanSubject: Help with another DataDirect processor error
Author: Kam Chan
Date: 10 Jul 2009 09:43 AM
Ivan,

Here they are:

- laforms:CA04130807()
declare function laforms:CA04130807($system as element(), $form as element()*, $requestId as xs:integer) as element()*


- laforms:CA04130807-impl
declare function laforms:CA04130807-impl($system as element(), $forms as element()*, $details as element()*, $requestId as xs:integer, $subRequestId as xs:integer) as element()*

- commonvars:getNamedInsured()
declare function commonvars:getNamedInsured($system as element()) as xs:string

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.