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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Jose Alberto CoronadoSubject: Problem with a function
Author: Jose Alberto Coronado
Date: 08 Jul 2004 03:45 AM
Hello, I need help. I have a problem with a Xquery:

<residenciaDomicilio>
{local:obtenerVivienda($idPersonaFisica)}
{local:obtenerVecinoDe($idPersonaFisica)}
</residenciaDomicilio>


The query calls two distinct functions. The code of this functions is very similar but not the same.
Here is the code:


declare function local:obtenerVivienda($id as xs:string) as element*
{
let $viviendas := for $doc in doc("../../documentos.xml")/documentos/documento,
$persona in doc($doc)//comparece[idPersonaFisica = $id]
//descripcion[atributo ="vive en"]
return $persona/valor
for $vivienda in distinct-values($viviendas)
return
<viveEn>
<atributo>vive en</atributo>
<valor>{$vivienda/text()}</valor>
</viveEn>
};


declare function local:obtenerVecinoDe($id as xs:string) as element*
{
let $vecindad := for $doc in doc("../../documentos.xml")/documentos/documento,
$persona in doc($doc)//comparece[idPersonaFisica = $id]
//descripcion[atributo ="vecino de"]
return $persona/valor
for $vecino in distinct-values($vecindad)
return
<vecinoDe>
<atributo>vecino de</atributo>
<valor>{$vecino}</valor>
</vecinoDe>
};

As you can see, both functions share almost the same code, but when I run the query, the first function doesn't crash but, after, an error message appears:

"Function obtenerVecinoDe doesn't match the function signature"

Do you know what is the possible cause of this error?

Thanks.

Postnext
(Deleted User) Subject: Re: Problem with a function
Author: (Deleted User)
Date: 08 Jul 2004 07:02 AM
Hi Jose,
the error is in both the function signatures: they have been declared as
returning "element*", but the correct spelling is "element()*".
Without the "()", they specify that the return type is 0 or more instances
of a type named "element", instead of specifying that you expects 0 or more
element nodes.
Also, in the body of the first function you wrote

for $vivienda in distinct-values($viviendas)
return
<viveEn>
<atributo>vive en</atributo>
<valor>{$vivienda/text()}</valor>
</viveEn>

but distinct-values returns simple values, not nodes; so $vivienda/text()
will report an error. The correct expression is using just {$vivienda},
like you do in the body of the second function.

Alberto


Posttop
Jose Alberto CoronadoSubject: Re: Problem with a function
Author: Jose Alberto Coronado
Date: 08 Jul 2004 07:38 AM
Thank you Alberto, I have tried it and the functions already work.
You have help me very much.

   
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.