Subject: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()*
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()*
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>
};