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
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Rusty ManesiyaSubject: Recursive function error
Author: Rusty Manesiya
Date: 05 Mar 2007 09:59 AM
I have a simple function that returns relations to the party, but fails with an error on second attempt to call the same function.

The function getParty gets recursively called inside the getPartyRelationship. I get the error when function tries call

[DataDirect][XQuery][err:XPTY0004]Error at line 6, column 21. Static type error. Types 'element(ID, DECIMAL_10_0)' and 'element(ID, xs:anyType)*' are invalid argument types for binary operator '='.

If i were to remove the code
"return local:getParty($relatedParty treat as element(PARTY))" from the getPartyRelationship function it works fine b/c there is no recursion happening.

Code
========================================================

declare function local:getParty($INPARTY as element(PARTY)) as element()*{

for $PARTY in collection("PARTY")/PARTY
where $PARTY/ID = $INPARTY/ID
return
<a:id>
{$PARTY/ID/text()}
</a:id>
union
<a:listOfRelationship>
{local:getPartyRelationship($INPARTY)}
</a:listOfRelationship>
};


declare function local:getPartyRelationship($INPARTY as element(PARTY))
as element(a:partyRelationship){

for $PARTYRELATIONSHIP in collection("PARTYRELATIONSHIP")/PARTYRELATIONSHIP
where $PARTYRELATIONSHIP/PARTY2ID = $INPARTY/ID
return
<a:partyRelationship>
<a:id>
{$PARTYRELATIONSHIP/PARTY2ID/text()}
</a:id>
<a:relatedParty>
{
let $relatedParty := collection("PARTY")/PARTY[ID = $INPARTY/ID]
return local:getParty($relatedParty treat as element(PARTY))
}
</a:relatedParty>
</a:partyRelationship>
};

let $SRCHPARTY := collection("AP_OWNER.PARTY")/PARTY[ID = 4926]
return
<a:listOfParty>
<a:party>
{local:getParty($SRCHPARTY)}
</a:party>
</a:listOfParty>

Postnext
(Deleted User) Subject: Recursive function error
Author: (Deleted User)
Date: 05 Mar 2007 12:20 PM
Hi Rusty,
the error occurs because the static typing of the ID sub-element of PARTY is not identical to the one coming from the collection (and in particular, its cardinality is zero-or-more).
You could try either adding /text() to both sides of the comparison, or changing $INPARTY/ID to be ($INPARTY/ID treat as element(ID)).

Hope this helps,
Alberto

Posttop
Rusty ManesiyaSubject: Recursive function error
Author: Rusty Manesiya
Date: 05 Mar 2007 12:24 PM
Thanks Alberto. We will go ahead and try that.

 
Topic Page 1 2 3 4 5 6 7 8 9 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.