- From: Jonathan Robie <jonathan.robie@datadirect.com>
- Date: Wed, 01 Mar 2006 16:06:24 -0500
- To: Frans Englich <frans.englich@telia.com>
- CC: public-qt-comments@w3.org
Hi Frans, The binding of an external function is implementation defined. In our implementation, DataDirect XQuery, a user can declare static Java functions or SQL functions as external functions, and they can be called within an XQuery. Here are some use cases: - Calling a Java function that invokes a Web Service, returning the result as XML to be processed within the query - Performing updates to a SQL database by fishing out the data from a complex XML document using XQuery If you don't say that a function is 'external', then the function must be available in the XQuery environment. If you say it is external, then the implementation knows it has to look for the function elsewhere. In our implementation, the namespace of the function determines whether it is a SQL function or a Java function. But the way an implementation locates functions is also implementation-defined. If the function can not be located, or if there are two functions with the same signature, I think the following errors should be raised: > err:XPST0017 > It is a static error <http://www.w3.org/TR/xquery/#dt-static-error> if > the expanded QName and number of arguments in a function call do not > match the name and arity of a function signature > <http://www.w3.org/TR/xquery/#dt-function-signature> in the static > context <http://www.w3.org/TR/xquery/#dt-static-context>. > > err:XQST0036 > It is a static error <http://www.w3.org/TR/xquery/#dt-static-error> to > import a module if the importing module's in-scope schema types > <http://www.w3.org/TR/xquery/#dt-is-types> do not include definitions > for the schema type names that appear in variable declarations, > function parameters, or function returns found in the imported module. > We do not have separate errors for external functions. Jonathan (personal opinion) -- Read my Blog: http://blogs.datadirect.com/jonathan_robie/ Learn XQuery: http://media.datadirect.com/download/docs/ddxquery/tutorial_query.html Learn XQJ (the JDBC for XQuery): http://www.datadirect.com/developer/xquery/topics/xqj_tutorial/ Get DataDirect XQuery: http://www.datadirect.com/products/xquery/ Frans Englich wrote: > Hi everyone, > > I'm confused by 'declare function ... external'. A heap of questions: > > * When is an 'external' declaration absolute required for achieving something? > Is it something more than a 'hint' to the compiler? From what I can tell a > compiler is required to do the same degree of type checking regardless of a > 'declare function ... external' declaration is in the prolog. > > * Can someone show a use case for 'external'? XQTS has none, from what I can > tell. > > * Is there a pattern for when an 'external' declaration should be added, or is > it implementation defined? > > * If an 'external' declaration specifies a function that doesn't exist, > shouldn't an error be raised? > > * Is this a query that will evaluate to true? > > declare function subsequence($sourceSeq as item()*, > $startingLoc as xs:double) as item()* external; > 1 + 1" > > Note, it doesn't define a function in the default namespace, it only declares > it. > > > With my currently limited knowledge, my feeling is I would like to see the > feature go away! > > > Frans > >
Received on Wednesday, 1 March 2006 21:06:16 UTC