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
bryan cravenSubject: Define function
Author: bryan craven
Date: 22 Mar 2006 09:39 PM
Every time I attempt to define a function as per the example below:
Stylus Studio bombs at the letter f in the word function. The error message is 'unrecognized letter f'. every article, tutorial, book I review shows this as the proper syntax. WHY ME?!

=================================================



define function toc($book-or-section as element())
as element()*

{
for $section in $book-or-section/section
return

<section>
{ $section/@* , $section/title , toc($section) }
</section>
}

<toc>

{
for $s in doc("xquery-book.xml")/book
return toc($s)

}
</toc>

Postnext
Minollo I.Subject: Define function
Author: Minollo I.
Date: 22 Mar 2006 09:50 PM
You are using an old syntax that has been changed in more recent versions of the XQuery specs (Stylus Studio is consistent with the November 2005 XQuery 1.0 Candidate Recommendation spec); you should define your function as

declare function local:toc($book-or-section as element())
as element()*

...and invoke it as local:toc(...)

Hope this helps,
Minollo

Postnext
bryan cravenSubject: Define function
Author: bryan craven
Date: 22 Mar 2006 10:32 PM
So I did as u suggested now I am getting an unexpected end of file error after the last semi-colon. Total code is below.



declare function local:toc($book-or-section as element())
as element()*

{
for $section in $book-or-section/section
return

<section>
{ $section/@* , $section/title , local:toc($section) }
</section>
};

Posttop
Minollo I.Subject: Define function
Author: Minollo I.
Date: 22 Mar 2006 10:44 PM
...you need to have a main body for your XQuery, something like...

declare function local:toc($book-or-section as element())
as element()*
{
for $section in $book-or-section/section
return
<section>
{ $section/@* , $section/title , local:toc($section) }
</section>
};

local:toc(<book><section><title>atitle</title></section></book>)

 
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.