[xquery-talk] How to define module local functions.

Michael Eichberg eichberg at informatik.tu-darmstadt.de
Tue Oct 5 13:35:11 PDT 2004


Hello,

 

I have written a library module which defines some variables and functions
for import by other (main or librarary) modules. However, some of the
methods should NOT be callable from other modules, be it library or main
modules, as those methods represent helper functions. Basically, I want to
do something similar to the example depicted below:

 

module namespace xirc        =
"http://www.st.informatik.tu-darmstadt.de/XIRC(5/5/04)";

 

declare namespace internal   = "XIRC-internal";

 

declare function xirc:isSerializable($class as element()*) as xs:boolean {

      if(some $name in $class/@name satisfies $name =
'java.io.Serializable')

      then

            fn:true()

      else

            internal:isSerializable($class)

};

 

declare function internal:isSerializable($class as element()*) as xs:boolean
{

      if (empty($class))

      then

            false()

      else if (some $name in $class/inherits/interface/@name satisfies $name
= 'java.io.Serializable')

      then

            true()

      else 

            (: we have to search the super types :)

            internal:isSerializable(xirc:directSupertypes($class))

};

 

 

In this example the xirc:isSerializable function is the one that has to be
callable by other modules and the internal:isSerializable function is the
one that should be private to this library module. Unfortunately this
example is not working as expected. My XQuery Processor (in this case Saxon
8.1) always generates an

    Function internal:isSerializable has not been declared

error (declaring the function internal:isSerializable before the other
"xirc:" function does not help either).

 

So, my question is, how can I achieve the desired behaviour, or should the
shown example work and that it does not work is a limitation / bug of Saxon?

 

 

Best regards,

Michael Eichberg

 

_________________________________________

Software Technology Group

Department of Computer Science

Darmstadt University of Technology

Alexanderstrasse 10

64289 Darmstadt

Phone.: +49 6151 16 3608

Fax:     +19 6151 16 5410

E-Mail:  <mailto:eichberg at informatik.tu-darmstadt.de>
eichberg at informatik.tu-darmstadt.de

WWW:  <http://www.st.informatik.tu-darmstadt.de/staff/Eichberg>
http://www.st.informatik.tu-darmstadt.de/staff/Eichberg

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20041005/e76404db/attachment-0001.htm


More information about the talk mailing list